[R] the less-than-minus gotcha

peter dalgaard pdalgd at gmail.com
Mon Feb 2 13:10:46 CET 2015


I'd rather say that it is good reason to use spaces around operators. Makes the code easier to read too. (_Possible_ to read for some.)

We've probably all done it. I did, once upon a time in S-Plus, on the results of a multi-day simulation study:

> <<nontrivial analysis>>$statistic
[1] -1.28
> sim <- sapply(1:10000, <<simulated nontrivial analysis>>$statistic)
.
. leave running
.
> mean(sim<-1.28) # get empirical p-value
[1] 1.28

??!?...  Uh-oh.....

On 02 Feb 2015, at 02:26 , Steve Taylor <steve.taylor at aut.ac.nz> wrote:

> All the more reason to use = instead of <-
> 
> 

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list