Re: [R] using ``-'' in function argument

2010-12-03 Thread Ivan Calandra
See below Le 12/3/2010 06:54, Berwin A Turlach a écrit : On Thu, 2 Dec 2010 23:34:02 -0500 David Winsemiusdwinsem...@comcast.net wrote: [...] Erik is telling you that your use of ncol-4 got evaluated to 4 and that the name of the resulting object was ignored, howevert the value of the

Re: [R] using ``-'' in function argument

2010-12-03 Thread Michael Bedward
It's only obvious when someone points it out :) fubar is not created because, in the test x 3 returned FALSE, which means the cat function doesn't get used, which means the y arg (fubar - 6) is never required and therefore not evaluated. Evil isn't it ? Michael On 3 December 2010 20:18, Ivan

Re: [R] using ``-'' in function argument

2010-12-03 Thread Ivan Calandra
Arf, yes it makes sense now! So the idea here is: never use - in function argument... Thanks for the explanation! Regards, Ivan Le 12/3/2010 10:48, Michael Bedward a écrit : It's only obvious when someone points it out :) fubar is not created because, in the test x 3 returned FALSE, which

Re: [R] using ``-'' in function argument

2010-12-03 Thread Berwin A Turlach
G'day Ivan, On Fri, 03 Dec 2010 10:54:58 +0100 Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Arf, yes it makes sense now! Well, my original post said: R has lazy evaluation and the assignment takes place when the function evaluates the argument :) So the idea here is: never use - in

Re: [R] using ``-'' in function argument

2010-12-03 Thread Ivan Calandra
Le 12/3/2010 11:35, Berwin A Turlach a écrit : G'day Ivan, On Fri, 03 Dec 2010 10:54:58 +0100 Ivan Calandraivan.calan...@uni-hamburg.de wrote: Arf, yes it makes sense now! Well, my original post said: R has lazy evaluation and the assignment takes place when the function evaluates the

Re: [R] using ``-'' in function argument

2010-12-03 Thread Claudia Beleites
On 12/03/2010 06:54 AM, Berwin A Turlach wrote: On Thu, 2 Dec 2010 23:34:02 -0500 David Winsemiusdwinsem...@comcast.net wrote: [...] Erik is telling you that your use of ncol-4 got evaluated to 4 and that the name of the resulting object was ignored, howevert the value of the operation was

[R] using ``-'' in function argument

2010-12-02 Thread Jinsong Zhao
Hi there, In function, it's usually using ``='' to assign default value for function argument. For newbie, it's possible to using ``- '' to assign value for function argument. Although it's not a correct way, R don't give any warning message. matrix(1:20, ncol - 4) [,1] [,2] [,3] [,4]

Re: [R] using ``-'' in function argument

2010-12-02 Thread Erik Iverson
On 12/02/2010 09:35 PM, Jinsong Zhao wrote: Hi there, In function, it's usually using ``='' to assign default value for function argument. For newbie, it's possible to using ``- '' to assign value for function argument. Although it's not a correct way, R don't give any warning message.

Re: [R] using ``-'' in function argument

2010-12-02 Thread David Winsemius
On Dec 2, 2010, at 10:47 PM, Erik Iverson wrote: On 12/02/2010 09:35 PM, Jinsong Zhao wrote: Hi there, In function, it's usually using ``='' to assign default value for function argument. For newbie, it's possible to using ``- '' to assign value for function argument. Although it's not a

Re: [R] using ``-'' in function argument

2010-12-02 Thread Berwin A Turlach
On Thu, 2 Dec 2010 23:34:02 -0500 David Winsemius dwinsem...@comcast.net wrote: [...] Erik is telling you that your use of ncol-4 got evaluated to 4 and that the name of the resulting object was ignored, howevert the value of the operation was passed on to matrix which used positional