[R-SIG-Mac] A shorthand for '<-'

Simon Urbanek simon.urbanek at r-project.org
Wed Nov 21 19:19:39 CET 2007


On Nov 21, 2007, at 11:45 AM, John Chambers wrote:

> Simon Urbanek wrote: James,
>
> On Nov 21, 2007, at 8:22 AM, James Milks wrote:
>
>> The '=' sign can be used in place of '<-'.  That's the only  
>> shorthand I know for R.
>>
>
> That's not a shorthand. `=` and `<-` are semantically different in R.
> Well, not really :-)
>
> It's true that the "=" operator won't be displayed as "<-", which I  
> agree was the original point.  But both assignment operators map  
> into the same internal C code, if you di g into the implementation.
>

I think we may be talking about different things here.

 > a=list(a=1,b=2)
 > ls()
[1] "a"

 > a<-list(a<-1,b<-2)
 > ls()
[1] "a" "b"

So `<-` and `=` are *not* semantically equivalent (where `<-` and `=`  
represent symbols in the parse tree).

And I suppose the misunderstanding comes from the interpretation of  
`=` and `<-`: I meant them as symbols (which is what I would expect  
since we're talking about writing R code) and you interpreted them as  
operators (which cold be expected given that I used backticks which  
was not wise ;)). You are right that `=` and `<-` are equivalent as  
operators:

 > `=`(a,list(`=`(a,1),`=`(b,2)))
 > ls()
[1] "a" "b"

I hope this makes things even more clear ;).

Cheers,
Simon


> The "=" operator was added in S4 to assuage folks with C/Java/ 
> awk .... backgrounds who didn't care  for the weird assignment   
> operator.  But "real" S and R users still seem to like "<-" better.
>
> Alexy was asking presumably about shorthands that you press/type in  
> the R Mac GUI which will result in `<-` being produced and those are  
> <Alt><-> (this comes from Emacs' "_" shortcut which you type on US  
> keyboard as <Shift><-> but given that the character _ is often used  
> these days, we created a variant where you use <Alt> instead of  
> <Shift>) and <Ctrl><=> (this one is simply a play on the equal sign  
> and should make sense on other keyboards, too). The last shorthand I  
> mentioned (<Alt>+<=>) is a direct translation of the ≠ sign (which  
> you get in other programs when pressing <Alt><=>) into R code.
>
> Cheers,
> Simon
>
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>



More information about the R-SIG-Mac mailing list