[R] questions on some operators in R

Greg Snow Greg.Snow at imail.org
Sat Jun 19 05:51:46 CEST 2010


That is really one reason stated in 2 pieces.

If you really care more about saving characters or key strokes over clarity of expression then you should really be using APL (http://en.wikipedia.org/wiki/APL_(programming_language)) (though I think APL was part of the inspiration for <-, though when S was first created that was a single key stroke).  And if you are really concerned with wear on your fingers then you need to switch to the Dvorak keyboard (http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard), though <- is still 3 key presses, but you don't need to move your fingers as much (I actually switched to Dvorak to cure myself looking at my fingers, but now I can type much faster than I ever did on QWERTY).

If you want to use "=", that is your decision, R-core decided to add it a while back (but I believe most if not all of them still use "<-").  I am more concerned that people understand the what are shortcuts and what they are shortcuts for and are aware of possible problems from using shortcuts rather than the more versatile tools that they are shortcuts for.  The longest distance between 2 points is a shortcut.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: Horace Tso [mailto:Horace.Tso at pgn.com]
> Sent: Friday, June 18, 2010 3:15 PM
> To: Erik Iverson; Greg Snow
> Cc: r-help
> Subject: RE: [R] questions on some operators in R
> 
> You still couldn't sway me into the <- camp. '=' is better for yet two
> more reasons,
> 
> 1. it requires one keystroke, rather than two,
> 
> 2. to type '<', one has to hold Shift then the ',' key, so it's a total
> of three strokes all together.
> 
> In a typical script, you have hundreds of assignment statements. Those
> extra keystroke translate into quite a bit more wear on your fingers.
> 
> H
> 
> -----Original Message-----
> From: Erik Iverson [mailto:eriki at ccbr.umn.edu]
> Sent: Friday, June 18, 2010 1:23 PM
> To: Greg Snow
> Cc: Horace Tso; li li; r-help
> Subject: Re: [R] questions on some operators in R
> 
> 
> 
> Greg Snow wrote:
> > Your example could also be used as an argument against allowing '='
> as a shortcut for <- after all if you are used to using <- (rather than
> =) then you will see the problem with x<-2 right off.  But if we
> eliminate <- and only use =, then how do you do:
> 
> >
> >> mean( x <- rnorm(100) )
> >
> > Or
> >
> >> system.time( output <- longrunningfunction(args) )
> >
> > Is
> >
> >> mean( { x=rnorm(100) } )
> >
> > Really and improvement?
> 
> Certainly not in my mind!
> 
> For me, here is certainly an undefinable aesthetic appeal to the '<-'
> assignment operator.  The visual requirement of seeing '<-' for me is
> so
> strong, that even when running example code from this list, I must
> replace all assignments done with '=' to '<-' before submitting them to
> R! I've also noticed that there seems to be an association between
> using
> '=' for assignments and writing code with 0 spaces per line in it.  Of
> course, I insist on fixing that before running the code, too.  :)



More information about the R-help mailing list