« New Feature: R Community Calendar | Main | Get advance notice of changes to R »

December 16, 2008

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a010534b1db25970b01053670c55e970b

Listed below are links to weblogs that reference Use = or <- for assignment?:

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

Duncan Murdoch points out a slight error: f(x <- 3) isn't the only syntax you can use to assign in a function call: f( (x=3) ) would also work. More in this r-help post.

Jens Oehlschlägel makes the point that because of lazy evaluation, f(x <- 3) isn't guaranteed to perform any assignment to x. His (good) advice: "do not assign in function arguments unless you have good reasons".

Using 2 keystrokes for an assignment operator is a pain, although it's nicer to read. Does anyone bother reassigning a key (is there an easy way to do this?) to print out an arrow operator, as per the original APL keyboard?


@Bulgakov the ESS package for emacs sets the underscore '_' to emit the arrow (<-).

Also I have a vague recollection that older versions of R allowed '_' to be used in place of the arrow; however this is no longer true.

I routinely use Tinn-R's macro recorder to load <- at the start of a session and use <- . Personally I think it makes for easier reading of the code

If you run R as an inferior process to emacs you can get <- with spaces before and after by simply pressing the key _ (underscore). Of course you need the ESS package for emacs.

Thanks for the clarification. I also noticed in the link you shared that <<- was used at some point. I've neither used nor tried that one.

R-Studio has Alt- as shortcut key combination for " <- ". Yes, it adds the surrounding spaces!

The vim R package also substitute "_" with " <- " just like the ESS package for Emacs.

http://www.vim.org/scripts/script.php?script_id=2628

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment


R for the Enterprise

Got comments or suggestions for the blog editor?
Email David Smith.
Follow revodavid on Twitter Follow David on Twitter: @revodavid

Search Revolutions Blog