Hi, Try this:
dat1<-read.table(text=" y A B C 0 1 1 2 0 1 2 1 1 1 1 2 0 1 1 2 1 1 1 2 1 1 2 1 0 1 2 2 ",sep="",header=TRUE) dat2<-aggregate(y~A+B+C,data=dat1,sum) dat2<-dat2[,c(4,1:3)] dat3<-dat2[with(dat2,rev(order(y,A,B,C))),] dat3 y A B C 2 2 1 1 2 1 1 1 2 1 3 0 1 2 2 A.K. ----- Original Message ----- From: Christopher Desjardins <cddesjard...@gmail.com> To: R help <r-help@r-project.org> Cc: Sent: Thursday, July 19, 2012 8:34 PM Subject: [R] Changing ungrouped cases to grouped cases Hi, I have my data the following way: y A B C 0 1 1 2 0 1 2 1 1 1 1 2 0 1 1 2 1 1 1 2 1 1 2 1 0 1 2 2 . . . And so on. How can I make my data look like the following: y A B C 2 1 1 2 1 1 2 1 0 1 2 2 . . . In other words how can I change my ungrouped cases into grouped cases? Thanks! Chris [[alternative HTML version deleted]] ______________________________________________ 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. ______________________________________________ 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.