[R] Is there any difference between <- and =

Simon Blomberg s.blomberg1 at uq.edu.au
Fri Mar 13 01:36:07 CET 2009


I think Venables' and Ripley's convention makes good sense:

http://www.stat.auckland.ac.nz/mail/archive/r-downunder/2008-October/000300.html

So we not only are explicit about what we are assigning, but where we
are assigning it.

Cheers,

Simon.

On Thu, 2009-03-12 at 17:10 -0700, David M Smith wrote:
> On Thu, Mar 12, 2009 at 8:29 AM, "Jens Oehlschlägel" <oehl_list at gmx.de> wrote:
> > Thus there is dangerous advice in the referenced blog which reads:
> > "
> > f(x <- 3)
> > which means "assign 3 to x, and call f with the first argument set to the value 3
> > "
> 
> The thrust of the blog post was the stylistic question of whether to
> use <- or = for assignment, not a recommendation to use constructs
> like this.  (In fact, the next line reads "This is a contrived example
> though, and never really occurs in real-world programming.")  But I've
> added your sound advice that such constructs are best avoided. I've
> never seen the need to perform assignments in function calls before,
> but I'll avoid them now knowing about potential for mischief from lazy
> evaluation. Thanks.
> 
> http://blog.revolution-computing.com/2008/12/use-equals-or-arrow-for-assignment.html
> 
> # David Smith
> 
> --
> David M Smith <david at revolution-computing.com>
> Director of Community, REvolution Computing www.revolution-computing.com
> Tel: +1 (206) 577-4778 x3203 (Seattle, USA)
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.




More information about the R-help mailing list