[R] NA preserved in logical call - I don't understand this behavior because NA is not equal to 0
Hadley Wickham
hadley at rice.edu
Sun Jul 18 20:52:50 CEST 2010
> The problem is in data.frame[ and any NA in a logical vector will return a
> row of NA's. This can be avoid by wrapping which() around the logical vector
> which seems entirely wasteful or using subset().
The basic philosophy that causes this behaviour is sensible in my
opinion: missing values must always be handled explicitly. Sure it's
a bit of a hassle, but it being explicit prevents you from making
major errors in an analysis.
In my opinion, the flaw is that R doesn't apply this philosophy
entirely consistently: I think factor and table should default to
exclude = NULL.
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
More information about the R-help
mailing list