[R] Warning message

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Thu Jul 25 11:29:45 CEST 2002


On Thu, 25 Jul 2002, [iso-8859-1] jimmy melinard wrote:

> i'm quite new in R and i don't understand why this
> statement doesn't work:
>
> > mode(mensuel$VARIANCE.PRIX)
> [1] "numeric"
> > storage.mode(mensuel$VARIANCE.PRIX)
> [1] "integer"
> > mean(mensuel$VARIANCE.PRIX)
> [1] NA
> Warning message:
> argument is not numeric or logical: returning NA in:
> mean.default(mensuel$VARIANCE.PRIX)

A bit short on details here.  mean.default starts

    if (!is.numeric(x) && !is.complex(x) && !is.logical(x)) {
        warning("argument is not numeric or logical: returning NA")
        return(as.numeric(NA))
    }

so your argument fails is.numeric(x).  Here's such an example

> mode(x)
[1] "numeric"
> storage.mode(x)
[1] "integer"
> is.numeric(x)
[1] FALSE
> class(x)
[1] "factor"

so I guess you are trying to take the mean of a factor.  That makes no
sense, and R rightly objects.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list