[R] help with aggregate()
Phil Spector
spector at stat.berkeley.edu
Wed Feb 16 02:18:52 CET 2011
Sam -
Since the error message said the argument wasn't numeric
or logical, that would be the source of your problem. What
is the result of
class(all$Value)
If it's 'character' or 'factor', that would explain the problem.
Provide more details for a (most likely) easy solution.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Tue, 15 Feb 2011, Sam Steingold wrote:
>> * Sam Steingold <fqf at tah.bet> [2011-02-14 18:42:40 -0500]:
>>
>> byFOO$Mean <- aggregate(all$Value, by = list(all$FOO), FUN = mean)$x;
>
> this fails with
>
> There were 50 or more warnings (use warnings() to see the first 50)
>> warnings()
> Warning messages:
> 1: In mean.default(X[[1L]], ...) :
> argument is not numeric or logical: returning NA
> 2: In mean.default(X[[2L]], ...) :
> argument is not numeric or logical: returning NA
> 3: In mean.default(X[[3L]], ...) :
> argument is not numeric or logical: returning NA
> 4: In mean.default(X[[4L]], ...) :
> argument is not numeric or logical: returning NA
> 5: In mean.default(X[[5L]], ...) :
> argument is not numeric or logical: returning NA
>
> note that there are absolutely no NAs in all$Value:
>> all(!is.na(all$Value))
> [1] TRUE
>
> --
> Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)
> http://iris.org.il http://www.memritv.org http://pmw.org.il
> http://camera.org http://mideasttruth.com http://dhimmi.com
> ((lambda (x) `(,x ',x)) '(lambda (x) `(,x ',x)))
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list