Skip to content
Prev 280666 / 398502 Next

aggregate function

On Dec 21, 2011, at 11:31 AM, jim holtman wrote:

            
And the aggregate version:

 > aggregate(x$case1, x["param"], FUN=paste, collapse=",")
   param     x
1     1     a
2     2 b,c,d
3     3     e
4     4     f

( Generally one uses the "[[" function for extraction, but using  "["  
returns a list which is what aggregate is designed to process as its  
second argument, whereas you would get an error with either of these:

aggregate(x$case1, x$param, FUN=paste, collapse=",")
aggregate(x$case1, x[["param"]], FUN=paste, collapse=",")
  )
David Winsemius, MD
West Hartford, CT