Using = has it's problems too.
For example,
print(fit <- lm(...))
Assigns the result of the lm call to fit and prints the results. This is
quite a useful trick actually.
print(fit = lm(...))
Throws an error.
Moral of story, computers do what you tell them, not what you meant.
Kevin
On 02/01/2015 08:26 PM, Steve Taylor wrote:
All the more reason to use = instead of <-
-----Original Message-----
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Bolker
Sent: Monday, 2 February 2015 2:07p
To: r-h...@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)!
--
Kevin E. Thorpe
Head of Biostatistics, Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016
______________________________________________
R-help@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.