On Jul 18, 2010, at 2:52 PM, Hadley Wickham wrote:
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.
How does this apply to the treatment of logical indexing in the
function "data.frame[" ? The returned value is not expected to have
the same number of rows as the source object and the profusion of
duplicate NA rows serves what purpose? Wouldn't it be more consistent
to have the constructs:
dfrm[which(logical_vector), ]
dfrm[logical_vector , ]
.... return the same object?
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/
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@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.