[R] Warning message

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Jul 25 11:49:33 CEST 2002


jimmy melinard <jmelinard at yahoo.fr> writes:

> hi!
> 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) 

It certainly looks odd...

I bet that the variable in question is a factor object, in which case
we have the effect that

> is.numeric(x)
[1] FALSE
> is.integer(x)
[1] TRUE
> mode(x)
[1] "numeric"

It's a complicated issue; I don't think it counts as a bug.

Factors really should not be treated as numeric vectors even if they
are internally stored as integers, so the point is rather that you
shouldn't expect is.numeric(x) and mode(x)=="numeric" to be the same
thing. 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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