[R] aggregate: "sum" not meaningful for factors

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Thu Jan 2 15:00:03 CET 2003


Tord Snall wrote:
> Dear all,
> I try to summarise my data per category using aggregate, but for some
> reason I get the error message "sum" not meaningful for factors even though
> my vector is numeric. The data set is shown below.
> Could someone please give a hint.
> Thanks in advance!
> Sincerely,
> Tord

aggregate requires the first argument to be numeric if you're using sum 
  or mean. The way you had it, aggregate was trying to sum your 
classification variable as well which is of class `factor'. Try the 
following instead.

> aggregate(list(tallstubbyta = test$tallstubbyta,
             list(ObjektID = test$ObjektID), sum)


More information about the R-help mailing list