[Rd] silent recycling in logical indexing
ccberry at ucsd.edu
Thu Jan 4 22:09:11 CET 2018
> On Jan 4, 2018, at 11:56 AM, Ben Bolker <bbolker at gmail.com> wrote:
> Sorry if this has been covered here somewhere in the past, but ...
> Does anyone know why logical vectors are *silently* recycled, even
> when they are incommensurate lengths, when doing logical indexing?
It is convenient to use a single `TRUE' in programmatic manipulation of subscripts in the same manner as using an empty subscript interactively:
> expr1 <- quote(mat)
> expr1[] <- TRUE
> expr1[] <- 2
 0 2 0
 0 2 0
More information about the R-devel