How best to learn R?

Alban Zeber writes:

I am wondering whether there is a reference (online or book) that you would recommend to someone who is interested in learning how to program in R.

Any thoughts?

P.S. If I had a name like that, my books would be named, “Bayesian Statistics from A to Z,” “Teaching Statistics from A to Z,” “Regression and Multilevel Modeling from A to Z,” and so forth.

27 thoughts on “How best to learn R?

  1. Many people have recommend the R in Nutshell book from O'Reilly, though it is mostly a rehashing of help files: http://oreilly.com/catalog/9780596801717

    Perhaps the best online resource for learning R is this collection of videos compiled by Jeromy Anglim: http://jeromyanglim.blogspot.com/2010/05/videos-o

    Once you have a basic understanding of the language, an excellent resource for all things R is the R tag on StackOverflow: http://stackoverflow.com/questions/tagged/r

    The R community on SO is a collection of extraordinarily helpful experts who can answer very specific questions.

  2. statmethods.net (Robert Kabacoff's Quick-R website) is pretty awesome for those coming from SPSS. Many of our RAs also seem to like the Use R! series of books from Springer (http://www.springer.com/series/6991). I personally found the best way to learn it was to take something I'd done in another stats package (SPSS or SAS) and try to do the same analysis in R. After a few months of this, I had example code for pretty much every type of analysis I did at the time, which made it much easier to use R full time and ditch the other products.

    Jon.

  3. You don't want to over-promise with a book title. I think "Bayesian Statistics from A to G" would be just fine.

  4. I liked the "Introduction to R" written by the authors of R:

    http://cran.r-project.org/manuals.html

    The link also gets you to the manuals on sys-admin details, internals, writing extensions, and the reference manual.

    After that, I usually just search within R or on the web.

    As for how to learn stats, well that's a different question. I really liked Regression from G to H (Gelman and Hill), which codes all the examples in R, and also goes into BUGS. I found it a good way to understand stats because coding the examples so they're executable makes the authors be very precise notationally.

  5. Ecological Models and Data in R by Ben Bolker is a great book for learning applied ways to manipulate data, formulate analyses, and generate graphics in R. The old classic Modern Applied Statistics in S-Plus is very good as well. And the documentation section on the R website has more documentation then you can throw a stick at, I tend to like stuff by Harrell.

    If you want to learn higher level programming, I've gotten a lot out of Software for Data Analysis by John Chambers.

  6. There is very good book for beginners being written by Longhow Lam: http://www.splusbook.com/RIntro/RCourse.pdf
    The wikibook about R (http://en.wikibooks.org/wiki/R_Programming) also describes more specific tasks; it also contains many easy examples of code that may be useful even for people already familiar with R.
    For more advanced aspects of language itself, books by Venables and Ripley may be useful (don't remember exact titles, something like "Modern statistics with S").

    Actually, there is great amount of resources (online books, blogs, thematic sites like inside-r.org) devoted to different aspects of R; so, possibilities of self-education are barely restricted in this case

  7. First, know your audience. Is this a book intended for someone who knows statistics, but not code? Someone who can code, but doesn't know statistics? Someone who does neither (presumably a student)? Someone who knows statistics and coding to some extent (e.g. Stata), just not R?

  8. I'd second Quick-R (on statsmethods.net linked to above) – I find the hard part in R is actually getting started with simple stuff, that's initially a bit confusing. Quick-R is pretty good dealing with that.

  9. These sites/blogs are on my RSS:
    Revolutions (http://blog.revolutionanalytics.com/)
    On R tip a day (well, not realy, but useful anyway…) http://onertipaday.blogspot.com/

    I would recommend "The R Book" as well.

    Finally, there was a similar question at Stackoverflow some time ago, but it wasn't a programming question and it was closed. It happens that I have the post on my googlereader =).
    It's a long list, so, sorry for the long comment.

    * An Introduction to R – W. N. Venables, D. M. Smith and the R Development Core Team
    * R for Beginners – Emmanuel Paradis
    * Using R for Data Analysis and Graphics: Introduction, Code and Commentary – J. H. Maindonald
    * simpleR: Using R for Introductory Statistics – John Verzani
    * The R Guide – W. J. Owen

    Not-free:
    * A Beginner’s Guide to R – Alain F. Zuur, Elena N. Ieno, Erik H.W.G. Meesters quite simple, excelent for beginners
    * A First Course in Statistical Programming with R – W. John Braun and Duncan J. Murdoch this one requires certain mathematical kills, but it's great, recommend
    * A Handbook of Statistical Analyses Using R – Brian S. Everitt and Ibrsten Hothorn
    * A Modern Approach to Regression with R – Simon J. Sheather
    * Analyzing Linguistic Data A Practical Introduction to Statistics Using R – R. H. Baayen
    * Applied Spatial Data Analysis with R – Roger S. Bivand, Edzer J. Pebesma and Virgilio Gómez-Rubio
    * Applied Statistics Using SPSS, STATISTICA, MATLAB and R – Joaquim P. Marques de Sá great book for those who are migrating frome SPSS and MATLAB to R
    * Bayesian Computation with R – Jim Albert good reference for social scientists
    * Data Analysis and Graphics Using R – an Example-Based Approach – John Maindonald, W. John Braun
    * Data Manipulation with R – Phil Spector recommend
    * Data Mashups in R – Jeremy Leipzig and Xiao-Yi Li demonstration of R's extensibility, concise and good reference
    * Dynamic Linear Models with R – Giovanni Petris, Sonia Petrone and Patrizia Campagnoli
    * Extending the Linear Model with R – Julian J. Faraway
    * ggplot2 – Elegant Graphics for Data Analysis – Hadley Wickham great one
    * Interactive and Dynamic Graphics for Data Analysis With R and GGobi – Dianne Cook and Deborah F. Swayne
    * Introduction to Applied Bayesian Statistics and Estimation for Social Scientists – Scott M. Lynch
    * Introduction to Scientific Programming and Simulation using R – Owen Jones, Robert Maillardet and Andrew Robinson
    * Introductory Statistics with R – Peter Dalgaard excelent for beginners
    * Lattice Multivariate Data Visualization with R – Deepayan Sarkar
    * Linear Models with R – Julian J. Faraway
    * Modern Applied Statistics with S – W. N. Venables and B. D. Ripley
    * Practical Regression and Anova using R – Julian J. Faraway
    * Practical Tools For Exploring Data and Models – Hadley Alexander Wickham [correct me if I'm wrong, but I think this one is free]
    * R for SAS and SPSS Users – Robert A. Muenchen great tool if you migrate from SPSS, as I did once upon a time…
    * R Graphics – Paul Murrell excelent book for learning low-level graph capabilities in R
    * R in a Nutshell: A Desktop Quick Reference – Joseph Adler great companion for programming in R
    * R in Action – Data Analysis and Graphics with R – Robert Kabacoff great book, even better author's site
    * Robust Statistical Methods with R – Jana Jurečková and Jan Picek
    * R Through Excel – Richard M. Heiberger and Erich Neuwirth great tool if you use MS Office
    * Software for Data Analysis – Programming with R – John M. Chambers recommend
    * Statistics and Data with R: An applied approach through examples – Yosef Cohen and Jeremiah Y. Cohen
    * Statistics: An Introduction using R – Michael J. Crawley similar to Daalgard's book
    * The R Book – Michael J. Crawley this is one of those R-bibles, thorough and complete R reference
    * Time Series Analysis and Its Applications With R Examples – Robert H. Shumway and David S. Stoffer
    * Time Series Analysis With Applications in R – Jonathan D. Cryer and Kung-Sik Chan
    * Wavelet Methods in Statistics with R – G. P. Nason

    ps.: the author of the post was someone called aL3xa

  10. I would also recommend the R Programming wikibook, which is a project of an open content textbook. It is still a draft but anyone can makes his own contribution.

  11. Perhaps everyone is expected to know this, but there is an even more extensive list at

    http://www.r-project.org/doc/bib/R-books.html

    Note that certain books widely deprecated in the R community are pointedly excluded.

    R is wonderful, but I can't resist a waggish comment: one reason there are now so many books on R is that the core documentation is not that great. On the other hand, R is also defensibly designed for those smart enough to think while they use it, and naturally you do get an awful lot for the nothing you pay.

  12. Nick:

    Hey, how come my book with Jennifer isn't on the list? I think people can learn a lot of useful R from it!

    Anon:

    You can get the link to appear by right-clicking (or whatever the equivalent is on the Mac). I recall that we looked into this once and decided it was too much trouble to fix.

  13. Andrew: I have absolutely no idea.

    I hadn't noticed that your book was among the excluded, and even if I had I wouldn't have presumed that it was a reflection of perceived low quality.

    I have noticed that another book that apparently sells very well is not included, and I do know that there are scathing formal reviews of it, but I would rather not name the book, especially as the implication of Ben's message may be that the author never sent an email about it. So, the pointed exclusion may be in my imagination, and I should withdraw the insinuation.

  14. I enjoyed the Introduction to R by Crawley – highly recommended. IIRC he has course notes on his web page.

    I'd love to read a computer science oriented textbook introducing all the sort of stuff you get in introductory object-oriented and functional data structures and algorithms programming courses. Then, in an ideal world, it would go on to stuff like using the statistical machinery to learn algorithms expressed in R. Actually, has anyone written about using R to learn programs and other highly structured symbolic beasts?

  15. The correct way to learn any language is to sit down and try to solve a problem in it, googling feverishly.

Comments are closed.