R-alpha: x[NA]
Peter Dalgaard BSA
p.dalgaard@kubism.ku.dk
23 Sep 1997 00:02:03 +0200
Thomas Lumley <thomas@biostat.washington.edu> writes:
> That is, the presence of any NA would result in selecting only element
> as.numeric(T)==1.
Aha... Of course that only applies when you enter logical vectors
using c(...), if they result from a comparison, then the type would be
logical NA anyway. So the problem is that c(...) converts to numeric
if just one element is.numeric() even if that element is NA. Hmm. I
suppose that could be handled differently by having c() explicitly
ignoring NA when deciding on type, but that probably leads to more
problems elsewhere?
> BTW, while you obviously can't mix logical and numerical references I
> think it's unfortunate that you can't mix numeric and name-based
> references like
> R> names(x)<-letters[1:4]
> R> x
> a b c d
> 1 2 3 4
> R> x[c("a",2)]
> Error: subscript out of bounds
>
> If you want a real example, suppose you had a model frame from which you
> wanted to extract the response (in position 1) and the variables whose
> names were in a vector nn
> mf[,c(1,nn)]
> appears to be the obvious solution.
I think that the possibility of setting names(x)<-4:1 will demonstrate
why that can't work... Besides, can you be sure that the dependent
variable is the first one in a model frame any more?
--
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-