I have a data frame df
with a fields count
and value
and want to transform it to a data frame with the column value
where each value of value
is repeated count
times.
I actually don't have an idea how to do this other than in a loop. Solutions involving plyr
or reshape2
(or both) are perfectly acceptable.
Here is an example of what I am looking for:
count value
2 10
1 20
to
value
10
10
20
Follow-up question
What if I had 3 fields value1, value2, value3
which had to be repeated based on count
?