[R] the less-than-minus gotcha

Steve Taylor steve.taylor at aut.ac.nz
Mon Feb 2 02:26:36 CET 2015


All the more reason to use = instead of <-


-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ben Bolker
Sent: Monday, 2 February 2015 2:07p
To: r-help at stat.math.ethz.ch
Subject: Re: [R] the less-than-minus gotcha

Mike Miller <mbmiller+l <at> gmail.com> writes:

> 
> I've got to remember to use more spaces.  Here's the basic problem:
> 
> These are the same:
> 
> v< 1
> v<1
> 
> But these are extremely different:
> 
> v< -1
> v<-1
> 

This is indeed documented, in passing, in one of the pages you listed:

http://tim-smith.us/arrgh/syntax.html

Whitespace is meaningless, unless it isn't. Some parsing ambiguities 
are resolved by considering whitespace around operators. See and
despair: x<-y (assignment) is parsed differently than x < -y (comparison)!

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list