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,967
  • 1
  • 12
  • 15
frank
  • 3,036
  • 7
  • 33
  • 65

0 Answers0