Re: [R] creating individual records from a frequency distribution

2014-10-22 Thread Sven E. Templer
With melt and rep you are close. If you combine them it works: library(reshape) # your data: df1 <- data.frame(area=c(1,2),group1=c(2,3),group2=c(1,5),group3=c(4,0)) df2<-data.frame(person_id=seq(1:15),area=c(rep(1,7),rep(2,8)),group_num=c(1,1,2,3,3,3,3,1,1,1,2,2,2,2,2)) # first melt d <- melt(df1

[R] creating individual records from a frequency distribution

2014-10-22 Thread Gavin Rudge
I've got data frame containing a simple frequency distribution of numbers of people in three age groups by area. df1<-data.frame(area=c(1,2),group1=c(2,3),group2=c(1,5),group3=c(4,0)) df1 I want to get a data frame with one record per person (in my case 15 of them) which would look like this, w