Hi,

My problem is as follows:

INPUT:
"Frequency" from one column and  value of "Piglets" from another one

OUTPUT:
Repeat this "Piglet" value as per the "Frequency"
i.e.
Piglet 1, Frequency 3, implies 1,1,1
Piglet 7, Frequency 2, implies 7,7

SOLUTION:
This is what I have tried so far:

1. A helper function:
> dput(fn.1)
function (df.1, vt.1)
{
    i = c(1)
    for (i in seq_along(dim(df.1)[1])) {
        print(i)
        temp = rep(df.1$Piglets[i], df.1$Frequency[i])
        append(vt.1, values = temp)
    }
}

2. A dummy data frame:
> dput(df.1)
structure(list(Piglets = 5:14, Frequency = c(1L, 0L, 2L, 3L,
3L, 9L, 8L, 5L, 3L, 2L)), .Names = c("Piglets", "Frequency"), class =
"data.frame", row.names = c(NA,
-10L))

3. A dummy vector to hold results:
> dput(vt.1)
1

4. Finally the function call:
fn.1(df.1, vt.1)

5. The results is:
[1] 1

PROBLEM:
The result is not a repetition of Piglet value as per their respective
frequencies.



Thanks in advance for guidance and help.

CheeRs !


p.s I have used caps for my heading / sections, nothing else is implied by
their use.

	[[alternative HTML version deleted]]

