0

I have a simple dataframe, and want to aggregate on both mean and count of each.

I have three steps:

aggregate(x$value1,list(x$col1),mean)
aggregate(x$value1,list(x$col1),nrow)
merge(d1,d2,by='Group.1')
colnames(m)=c('col1','mean','count')

I am sure there is a more efficient way to do this in R.

Any suggestions?

Rohit
  • 1,916
  • 1
  • 12
  • 13
frank
  • 2,346
  • 5
  • 25
  • 55

0 Answers0