Re: [Rd] silent recycling in logical indexing

2018-01-04 Thread William Dunlap via R-devel
I have never used this construct. However, part of my job is seeing how well CRAN packages work in our reimplementation of the R language and I am continually surprised by the inventiveness of package writers. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Jan 4, 2018 at 1:44 PM, Ben Bolke

Re: [Rd] silent recycling in logical indexing

2018-01-04 Thread Berry, Charles
> On Jan 4, 2018, at 1:44 PM, Ben Bolker wrote: > > Chuck: I don't see how this example represents > incomplete/incommensurate recycling. It doesn't. I took your subject line to be the theme of your posting and `incommensurate lengths' to be an instance used to emphasize how silent recycli

Re: [Rd] silent recycling in logical indexing

2018-01-04 Thread Ben Bolker
PS I'm tempted to insert a warning at this point and see how often it actually gets triggered ... On Thu, Jan 4, 2018 at 4:44 PM, Ben Bolker wrote: > Hmm. > > Chuck: I don't see how this example represents > incomplete/incommensurate recycling. Doesn't TRUE replicate from > length-1 to length-3 i

Re: [Rd] silent recycling in logical indexing

2018-01-04 Thread Ben Bolker
Hmm. Chuck: I don't see how this example represents incomplete/incommensurate recycling. Doesn't TRUE replicate from length-1 to length-3 in this case (mat[c(TRUE,FALSE),2] would be an example of incomplete recycling)? William: clever, but maybe too clever unless you really need the speed? (The c

Re: [Rd] silent recycling in logical indexing

2018-01-04 Thread Berry, Charles
> On Jan 4, 2018, at 11:56 AM, Ben Bolker 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 s

Re: [Rd] silent recycling in logical indexing

2018-01-04 Thread William Dunlap via R-devel
One use case is when you want to extract every third item, starting with the second, of an arbitrary vector with x[c(FALSE, TRUE, FALSE)] instead of x[seq_along(x) %% 3 == 2] Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Jan 4, 2018 at 11:56 AM, Ben Bolker wrote: > > Sorry if t