[R] Adding rows based on column value
vikas.bansal at kcl.ac.uk
Thu Jul 14 19:46:50 CEST 2011
I have tried that also.But it is showing this error-
aggregate(file[,3:6], by = list(file[,2]), FUN = sum)
Error in FUN(X[[1L]], ...) : invalid 'type' (character) of argument
Kings College London
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Ben Bolker [bbolker at gmail.com]
Sent: Thursday, July 14, 2011 6:24 PM
To: r-help at stat.math.ethz.ch
Subject: Re: [R] Adding rows based on column value
Bansal, Vikas <vikas.bansal <at> kcl.ac.uk> writes:
> I am using this-
> aggregate(x = file[,3:6], by = list(file[,2]), FUN = "sum")
Better, although still not reproducible (please *do* read the posting
guide -- it is listed at the bottom of every R list post and is the
*first* google hit for "posting guide" (!); search for
"Examples"). What about removing the quotation marks around "sum"?
aggregate(x = file[,3:6], by = list(file[,2]), FUN = sum)
> but I think this is not a right way.
> Because we cannot use "sum" to add.That is
> why I was asking for help.
R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help