Saturday, 15 June 2013

r - Splitting values on the basis of count column -



r - Splitting values on the basis of count column -

i have dataframe 2 columns

>mydata <- data.frame(obj = c(1,2,3,2), count = c(2,3,1,4)) >mydata obj count 1 1 2 2 2 3 3 3 1 4 2 4

i want split obj column based on count atomic objects (1, 1, 2, 2, 2, 3, 2, 2, 2, 2) yeah reverse of table function. there function doing in r?

p.s: simple loop can trick, sense utilize inbuilt efficient functions.

try

rep(mydata$obj,mydata$count)

r

No comments:

Post a Comment