Skip to content
 

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 Comments

  1. Martin says:

    This web page might be useful.
    http://www.statmethods.net/graphs/index.html

  2. Drew Conway says:

    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.

  3. eric novik says:

    If you live in New York you should come to the New York R Statistical Programming Meetup: http://www.meetup.com/nyhackr/
    There are similar groups in other cities. I think that the interactive format makes for a better learning experience.

  4. Jon Westfall says:

    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.

  5. David says:

    Introductory statistics with R by Peter Dalgaard is a good book.

  6. Phil says:

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

  7. Bob Carpenter says:

    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.

  8. Patrick McCann says:

    I really enjoyed the Faraway book as I was learning

  9. p-ter says:

    Maindonald and Braun, Data Analysis and Graphic using R
    http://www.amazon.com/Data-Analysis-Graphics-Usin

  10. Matthew says:

    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.

  11. Alex Ishkin says:

    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

  12. Ken Kleinman says:

    If you know SAS, I humbly suggest my book with Nick Horton:

    http://www.math.smith.edu/sasr

    which facilitates the approach Jon Westfall recommends above. We also run the sas-and-r blog with numerous worked examples.

  13. Nick says:

    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?

  14. dggoldst.myopenid.co says:

    I'm partial to the following two R video tutorials to get up and running with R (Full disclosure: I made them).

    http://www.decisionsciencenews.com/2007/09/26/r-v

    http://www.decisionsciencenews.com/2007/10/02/r-v

    Also, I was able to do certain things a lot faster after reading the book "Data Manipulation with R" by Phil Spector.

  15. Sebastian says:

    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.

  16. Manoel Galdino says:

    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

  17. PAC says:

    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.

  18. Nick Cox says:

    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.

  19. Anonymous says:

    Off-topic comment:

    When I click on any link on this blog the browser's url remains at http://www.stat.columbia.edu/~gelman/blog/ and it does not change to the linked url. Is there a way to fix this?

    Thanks

  20. Andrew Gelman says:

    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.

  21. Ben Bolker says:

    Andrew:

    To get your book on the "R books" page,
    I think you just need to send an e-mail to Kurt Hornik,
    with an appropriate entry in the same format as
    http://www.r-project.org/doc/bib/R-books_bib.html

    (That's what I did, anyway.)

  22. Nick Cox says:

    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.

  23. http://rseek.org/ is useful. You can even install a shortcut you can search it using the search bar in firefox.

  24. I'm a fan of the Dalgaard book for getting started.

    Also, I ran an R Study Group here at UPenn for the Linguistics / CogSci group. All the notes are online, and I tried to keep them as lucid as possible.

    http://www.ling.upenn.edu/~joseff/rstudy

  25. Andy Fugard says:

    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?

  26. John says:

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