[R] Summarizing For Values with Multiple categories

Alison Waller alison.waller at embl.de
Sun Oct 24 01:03:26 CEST 2010


Thanks!

I tried reading the help for aggregate and can't figure out which form  
of the formula I am using, and therefore the syntax.

I'm getting the below error.

 > aggregate(counts ~ ind, merge(stack(CAT2COG), df, by = 1), sum)
Error in as.data.frame.default(x) :
   cannot coerce class "formula" into a data.frame
 > aggregate(counts ~ Cats, merge(stack(CAT2COG), df, by = 1), sum)
Error in as.data.frame.default(x) :
   cannot coerce class "formula" into a data.frame
 > Cats
[1] A B C D E
Levels: A B C D E
 > aggregate(counts ~ COGs, merge(stack(CAT2COG), df, by = 1), sum)
Error in as.data.frame.default(x) :
   cannot coerce class "formula" into a data.frame
On 24-Oct-10, at 12:50 AM, Gabor Grothendieck wrote:

>> aggregate(counts ~ ind, merge(stack(CAT2COG), df, by = 1), sum)



More information about the R-help mailing list