tags:

views:

300

answers:

5
+5  Q: 

Common R idioms

What good resources are there for R idioms, in the same line as there are for Java and Python?

+3  A: 

This is a very interesting question -- R is indeed full of idioms, and the situation is made even more difficult by the fact that there are many idioms for data analysis, in addition to the more general programming ones. Combined with R's expressiveness and its penchant for violating the principle of least surprise, this often makes the learning curve a bit steeper than one would like.

Personally, I picked up most of what I know by reading help, reading various tutorials and tip collections, and occasionally looking at source code of built-in functions. R FAQ has useful tidbits to start with. Revolution Computing has links to good resources, particularly for programmers. Also, I found Howard Seltman's collection of tips and links to be useful; I would bet that links on that page would cover most useful R idioms, but I am curious to see what else is out there.

Leo Alekseyev
+5  A: 

There is Rosetta Code which presents many common programming tasks in different programming languages. Then there is a blog post by Stephen Turner that lists several ressources for programmers coming from other languages, for instance you can find slides from Drew Conway who compares Python with R.

Karsten W.
+2  A: 

This may or may not help you on your quest to figuring out R. But back when I was getting accustomed to R, I found that matlab to R dictionaries helped quite a bit (i.e. assuming you know how to use matlab). I can't seem to find the one I used, but found this one, which seems to illustrate things nicely.

ast4
+3  A: 

Easy: 2200+ packages and counting on CRAN :)

Actually, jokes aside, the best description I have read was in Chambers (2008).

Dirk Eddelbuettel
+1 It always comes back to Chambers. :)
Shane
+7  A: 

I would primarily recommend the R Inferno. In particular, study section 3 on vectorization, which is probably the key concept in R programming.

Beyond that, I would second Dirk's recommendation of John Chambers book.

Going a step farther: the R language is derived primarily from Scheme. One of the best ways to deeply understand R programming (as compared to a language like Java or C) is by learning about functional programming. For this, the best resource might be SICP (the "Structure and Interpretation of Computer Programs", available free online) which uses Scheme. You can find the relevant video lectures online as well: MIT 6.001 and Berkeley 61a.

Shane
+1 for the R Inferno -- one of the most useful R tutorials I've read, I cant' believe I forgot to mention it :) It both teaches you R idioms and helps avoid some nasty traps.
Leo Alekseyev