HI Farnoosh, You can use ?dcast() library(plyr)
dcast(DataA,ID~Var1,value.var="Var2") # ID A B #1 1 100 50 #2 2 200 100 A.K. On Thursday, February 13, 2014 2:59 PM, farnoosh sheikhi <farnoosh...@yahoo.com> wrote: Hi Arun, I hope all is well. I need to aggregate a data like below: DataA ID Var1 Var2 1 A100 1B50 2 A200 2B100 The transformed data should be like below: ID AB 1100 50 2200100 Thanks a lot. Regards, Farnoosh Sheikhi ______________________________________________ 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.