[R] Aggregation

arun smartpink111 at yahoo.com
Thu Feb 13 22:29:48 CET 2014


Sorry, the library should be 
library(reshape2)





On Thursday, February 13, 2014 4:27 PM, arun <smartpink111 at yahoo.com> wrote:
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_81 at 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




More information about the R-help mailing list