Re: [R] is it safe to replace every "<-" by "=" in R code?

From: Richard M. Heiberger <rmh_at_temple.edu>
Date: Sun, 13 Jan 2008 20:16:33 -0500

Most R users believe that there is a clear distinction between " <- " and "=".
Gabor's example is a wonderful illustration of that distinction. Most users recommend " <- " for assignment for greater clarity and readability.
The important characteristic for readability is the space on both sides of the
assignment arrow. Without spacing for human legibility anything will look bad.

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of Gabor Grothendieck
Sent: Sunday, January 13, 2008 05:50 PM
To: Nasser Abbasi
Cc: r-help_at_stat.math.ethz.ch
Subject: Re: [R] is it safe to replace every "<-" by "=" in R code?

No.

> f <- function(a = 3, b = 4) a-b
> f(b = 10)
[1] -7
> f(b <- 10)
[1] 6

but if you only replace it in the context:

x <- ...

then it should be ok.

On Jan 13, 2008 5:41 PM, Nasser Abbasi <nma_at_12000.org> wrote:
> hi;
>
> When I first started looking at R code, I thought that the <- notation for
> assignment made the code less readable (and I still do). Then I found
that
> now one can use "=" in place of "<-" for assignment (I understand this
> started since version 1.4). Anyway, I think using "=" makes the code much
> more readable.
>
> I was wondering, would it be safe if I replace all the occurrences of "<-"
> by "=" in any function of R? Or do you think this will break things?
>
> I like to look at a pretty code, and I just can't stand looking at those
> "<-" any more :)
>
> I am using latest version of R on windoz platform.
>
> thanks
> Nasser
>
> ______________________________________________
> 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.
>



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.

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. Received on Mon 14 Jan 2008 - 01:19:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jan 2008 - 03:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive