[R] advice/opinion on "<-" vs "=" in teaching R

(Ted Harding) Ted.Harding at manchester.ac.uk
Fri Jan 15 07:57:23 CET 2010


On 15-Jan-10 04:06:55, Rolf Turner wrote:
> On 15/01/2010, at 4:45 PM, Erin Hodgess wrote:
>> Hi R People:
>>
>> I'm teaching a statistical computing class using R starting
>> next week (yay!) and I have an opinion type question, please.
>>
>> I'm old school and use "<-" in an assignment.
>>
>> However, I'm starting to see the "=" in the literature.
>>
>> Which should I use or does it matter, please?
> 
> It's basically a matter of taste.  But people with ***good***
> taste use "<-". :-)
> 
> Constructions such as "a = a+3" are toadally illogical whereas
> "a <- a + 3"
> makes perfect sense.
> 
> However I'm sore afraid that as is always the case, good taste
> fails and bad taste prevails.  I.e. "=" for assignment will
> take over.

Yes, water flows down-hill -- unless we build control structures ...

> Personally I shall resist as long as possible, i.e. until "<-"
> is removed from the syntax structure by R Core.
> 
>       cheers,
>               Rolf

There is at least one context where the distinction must be
preserved. Example:

  pnorm(1.5)
  # [1] 0.9331928
  pnorm(x=1.5)
  # Error in pnorm(x = 1.5) : unused argument(s) (x = 1.5)
  pnorm(x<-1.5)
  # [1] 0.9331928
  x
  # [1] 1.5

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 15-Jan-10                                       Time: 06:57:16
------------------------------ XFMail ------------------------------



More information about the R-help mailing list