[R] methods on missing data
zeileis at ci.tuwien.ac.at
Wed Jun 6 17:12:55 CEST 2001
Maciej.Hoffman-Wecker at evotecoai.com wrote:
> Hello everybody!
> I have 2 >issues< concerning methods applied to missing data.
> I think they're bugs, but who knows.
I don't think so :-)
> 1. var(NA) returns
> Error in var(NA) : missing observations in cov/cor
> instead of NA.
Because you didn't tell var() that it should remove missing values, it
warns you that there are missing values. If you want to remove them the
following gives the answer you expected.
> var(NA, na.rm=TRUE)
> I expanded the summary-function to my.summary
> including SDev, in order to use it with tapply, which crashes
> in case of groups with no valid data.
> 2. is a similar problem. I use tapply with hist. On groups
> without valid data it crashes, like hist(as.numeric(c(NA)))
> Error in pretty(rx, n = nnb, min.n = 1) : x must be numeric
> hist(as.numeric(c(NA)),breaks=c(1,2)) works, as it does not use "pretty".
> I know these are very special cases, but unfortunately they kill the whole
Maybe you should check before if your vector contains only NA's, e.g.,
Hope this helps
Institut für Statistik
Technische Universität Wien
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