R-beta: logical indexing on a list

Douglas Bates bates at stat.wisc.edu
Sun Aug 10 23:50:19 CEST 1997


I haven't had a chance to track this one down in the source code yet.
I am reporting it here in case someone else has time to look at it.

When using a logical vector as an index on a vector, things work as
expected until you get to a list for which the indices are all FALSE.
> tn <- 1:2
> tn[c(T,T)]
[1] 1 2
> tn[c(F,T)]
[1] 2
> tn[c(F,F)]
integer(0)
> tt <- list(foo = 1, bar = 2)
> tt[c(T,T)]
$foo
[1] 1

$bar
[1] 2

> tt[c(F,T)]
$bar
[1] 2

> tt[c(F,F)]
Error: attempt to set an attribute on NULL
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 mailing list