Re: [Rd] A trap for young players with the lapply() function.

2017-03-28 Thread Rolf Turner
On 29/03/17 11:03, William Dunlap wrote: I think that the suggestion I made, in response to a posting by Barry Rowlingson, that the first argument of lapply() be given the name of ".X" rather than just-plain-X, would be (a) effective, and (b) harmless. It would break any call to *apply() that

Re: [Rd] A trap for young players with the lapply() function.

2017-03-28 Thread William Dunlap via R-devel
>I think that the suggestion I made, in response to a posting by Barry >>Rowlingson, that the first argument of lapply() be given the name of ".X" >rather >than just-plain-X, would be (a) effective, and (b) harmless. It would break any call to *apply() that used X= to name the first argument. T

Re: [Rd] A trap for young players with the lapply() function.

2017-03-28 Thread Rolf Turner
On 28/03/17 15:26, Charles C. Berry wrote: On Mon, 27 Mar 2017, Rolf Turner wrote: From time to time I get myself into a state of bewilderment when using apply() by calling it with FUN equal to a function which has an "optional" argument named "X". E.g. xxx <- lapply(y,function(x,X){cos(x

Re: [Rd] `[` not recognized as a primitive in certain cases.

2017-03-28 Thread Joris Meys
Thank you gents, I overlooked the subtle differences. On Tue, Mar 28, 2017 at 2:49 PM, Lukas Stadler wrote: > “typeof” is your friend here: > > > typeof(`[`) > [1] "special" > > typeof(mc[[1]]) > [1] "symbol" > > typeof(mc2[[1]]) > [1] "special" > > so mc[[1]] is a symbol, and thus not a primiti

Re: [Rd] `[` not recognized as a primitive in certain cases.

2017-03-28 Thread Lukas Stadler
“typeof” is your friend here: > typeof(`[`) [1] "special" > typeof(mc[[1]]) [1] "symbol" > typeof(mc2[[1]]) [1] "special" so mc[[1]] is a symbol, and thus not a primitive. - Lukas > On 28 Mar 2017, at 14:46, Michael Lawrence wrote: > > There is a difference between the symbol and the function

Re: [Rd] `[` not recognized as a primitive in certain cases.

2017-03-28 Thread Michael Lawrence
There is a difference between the symbol and the function (primitive or closure) to which it is bound. This: mc2 <- as.call(list(`[`,iris,2,"Species")) Evaluates `[` to its value, in this case the primitive object, and the primitive itself is incorporated into the returned call. If you were to d

[Rd] `[` not recognized as a primitive in certain cases.

2017-03-28 Thread Joris Meys
Dear, I have noticed this problem while looking at the following question on Stackoverflow : http://stackoverflow.com/questions/42894213/s4-class-subset-inheritance-with-additional-arguments While going through callNextMethod, I've noticed the following odd behaviour: mc <- call("[",iris,2,"Spe