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

December 16, 2008

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

Given the absolute noise of programming, the extra keystroke for 'assigns' (that is '<-' vs '=') is no convenience. We are not that close to ultimate efficiency.

The comments to this entry are closed.

Search Revolutions Blog




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