R-beta: logical indexing on a list

Douglas Bates (bates@stat.wisc.edu)
10 Aug 1997 16:50:19 -0500


To: R@stat.auckland.ac.nz
Subject: R-beta: logical indexing on a list
From: Douglas Bates <bates@stat.wisc.edu>
Date: 10 Aug 1997 16:50:19 -0500

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@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=