> # 2. create one new row for each case in level.1 and level.2 > > # the new reshaped data.frame would should look like this: > > # indiv factor covar case.id > # A level.1 4.614105 1 > # A level.1 4.614105 2 > # A level.2 31.064405 1 > # A level.2 31.064405 2 > # A level.2 31.064405 3 > # A level.2 31.064405 4 > # A level.1 19.185784 1 > # A level.2 48.455929 1 > # A level.2 48.455929 2 > # A level.2 48.455929 3 > # etc... > > #############################
This works for me. melt(my.dat,id=c("indiv","covar.1","covar.2"))->my.dat.1 names(my.dat.1)[4:5]<-c("level","case.id") melt(my.dat.1,id=c("indiv","level","case.id"))->my.dat.2 Vikas ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.