> On Jan 4, 2018, at 11:56 AM, Ben Bolker <bbol...@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: > mat<-diag(1:3) > expr1 <- quote(mat[]) > expr1[[3]] <- TRUE > expr1[[4]] <- 2 > eval(expr1) [1] 0 2 0 > mat[,2] [1] 0 2 0 HTH, Chuck ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel