R-alpha: x[NA]

Peter Dalgaard BSA p.dalgaard@kubism.ku.dk
22 Sep 1997 14:04:47 +0200

Just curious. Current logic in both R and Splus has

> (1:3)[c(T,F,NA)]
[1]  1 NA

Does anyone know *why*? It makes sense for integer indexing, but for
logicals it seems to have some strange consequences - if you divide a
dataframe according to some criterion, you get as many NA-filled
records as there are missing values of the criterion added to *both*
the group that satisfies the criterion and to those that do not.

One reason could be that since NA is logical by default, you would be
getting awkward consequences of the type x[NA] == real(0), but
x[c(NA,1)] == c(NA,5.3), but why is NA logical by default, then? 

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