[R] Adding rows based on column value
    Bert Gunter 
    gunter.berton at gene.com
       
    Thu Jul 14 19:55:05 CEST 2011
    
    
  
Yes, because from your previous posts, you appeared to have read in
the data as "character":
file=read.table("file.txt",fill=T,colClasses = "character",header=T)
But, of course, without a reproducible example, one cannot be sure.
-- Bert
On Thu, Jul 14, 2011 at 10:46 AM, Bansal, Vikas <vikas.bansal at kcl.ac.uk> wrote:
> 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
>
>
>
> Thanking you,
> Warm Regards
> Vikas Bansal
> Msc Bioinformatics
> 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
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
-- 
"Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions."
-- Maimonides (1135-1204)
Bert Gunter
Genentech Nonclinical Biostatistics
    
    
More information about the R-help
mailing list