Isn't this what you want? > x <- data.frame(id=rep(1:2, each=2), test = rep(c("test1","test2"), 2), + score = c(120, 34, 132, 28)) > x id test score 1 1 test1 120 2 1 test2 34 3 2 test1 132 4 2 test2 28 > reshape(x, timevar="test", direction="wide") id score.test1 score.test2 1 1 120 34 3 2 132 28
HTH, Andy > -----Original Message----- > From: Bruce Coate [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 17, 2003 1:30 PM > To: [EMAIL PROTECTED] > Subject: [R] Transpose Data Frame Question > > > Hi, > > I have a data.frame that has 3 columns (ID, Test, Result) and > looks like this > > 1, Test1, 120 > 1, Test2, 34 > 2, Test1, 132 > 2, Test2, 28 > etc > > I would like to turn it around so that it looks like this > > 1, 120, 34 > 2, 132, 28 > etc > > I have played around some with t and reshape, but with no success. > Any suggestions or hints would be greatly appreciated. > Thanks, > Bruce > > > --------------------------------- > > > [[alternative HTML version deleted]] > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo> /r-help > ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help