From J.C.Rougier@durham.ac.uk  Mon Oct 16 12:27:06 2000
From: J.C.Rougier@durham.ac.uk (Jonathan Rougier)
Date: Mon, 16 Oct 2000 12:27:06 +0100 (BST)
Subject: [Rd] Logical indexing
Message-ID: <Pine.GSO.4.20.0010161220350.2598-100000@laplace>

Am I right in thinking that R.1.1.1 is using a different convention (to
previous versions) regarding logical indexing of vectors and lists?  I
feel that supplying a boolean of the wrong length should generate an
error, but now

> (1:4)[rep(TRUE, 10)]
 [1]  1  2  3  4 NA NA NA NA NA NA

I think that if this effect is desired then

> (1:4)[1:10]

would be the appropriate syntax.  Preserving the integrity of the logical
operator provides a useful error trap for programmers who specifically
want to avoid this kind of behaviour.

Cheers, Jonathan.

Jonathan Rougier                       Science Laboratories
Department of Mathematical Sciences    South Road
University of Durham                   Durham DH1 3LE
http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Logical indexing
Jonathan Rougier