[R] questions on some operators in R

Joris Meys jorismeys at gmail.com
Sat Jun 19 02:52:20 CEST 2010


On Fri, Jun 18, 2010 at 8:15 PM, Horace Tso <Horace.Tso at pgn.com> wrote:
...
>> which(x<-2)
> Error in which(x <- 2) : argument to 'which' is not logical
>
> Oops, what happened? If you look up help pages for 'which', you'd find no clue.
You just have to look at the error message. R adds the spaces and you
see immediately why it interpreted the code wrongly.

I do like readable code though. "<-" and spaces add a bit in writing
time, but save a whole bunch in debugging time. Especially a couple of
weeks after you wrote the code. And I'm not exactly an S old-timer.
This even comes from somebody who loves Perl ;-) .

Cheers
Joris


-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php



More information about the R-help mailing list