Skip to content
Prev 333715 / 398506 Next

Generating Frequency Values

On 26-11-2013, at 15:59, Burhan ul haq <ulhaqz at gmail.com> wrote:

            
There is a lot wrong with your function.
You should assign the result of append to vt.1
The function should return vt.1
Use seq_len instead of seq_along.

The function should be something like this

fn.1 <- function (df.1, vt.1)
{
   for (i in seq_len(length.out=dim(df.1)[1])) {
       print(i)
       temp = rep(df.1$Piglets[i], df.1$Frequency[i])
       vt.1 <- append(vt.1, values = temp)
   }
   vt.1
}

But Sarah?s solution is the way to go.

Berend