Re: [R] aggregate data.frame based on column class

2013-01-11 Thread Ista Zahn
Please see in line. On Fri, Jan 11, 2013 at 10:07 AM, Martin Batholdy batho...@googlemail.com wrote: Hi, When using the aggregate function to aggregate a data.frame by one or more grouping variables I often have the problem, that I want the mean for some numeric variables but the unique

Re: [R] aggregate data.frame based on column class

2013-01-11 Thread arun
Hi, Hope this is what you meant. #data1 aggregate(.~group+gender,data=data1,mean) #  group gender x #1 2  f  1.750686 #2 1  m -1.074343 A.K. - Original Message - From: Martin Batholdy batho...@googlemail.com To: r-help@r-project.org r-help@r-project.org Cc:

Re: [R] aggregate data.frame based on column class

2013-01-11 Thread arun
Hi, May be I misunderstood ur question. You could do this: res-aggregate(.~group,data=data1,mean) res$gender-data1$gender[match(res$gender,as.numeric(data1$gender))]  res #  group x gender #1 1 -1.074343  m #2 2  1.750686  f A.K. - Original Message - From: