Thursday, February 7, 2013

Getting staRted with R.

As a PhD student and researcher, I often hear friends and colleagues say that they want to learn R, but that the learning curve is so steep that they can't seem to get started.  It's true that learning any tool as powerful as R can be confusing at first, especially if you are not accustomed to typing commands in a terminal.  That said, there are TONS of resources available for learning R.  This post describes some of the resources that I have found most useful in my jouRney.

Online Resources
  • O'Reilly Code School TryR - this is a truly fantastic online interactive introduction to learning basic skills in R.  Warning: the tutorial has a persistent pirate metaphor.
  • twotorials - 2 minute videos that teach you how to do simple tasks in R. "got two minutes? Learn some statistical programming in R.  Its easy, free, and FUN!"
  • Quick-R is a fast way to learn what you need to get started.  I found this site after I had learned the basics, but it really seems great.  Thanks for reminding me about this resource,  a Tom.
  • flowingdata tutorials - these are focussed tutorials on specific topics, like dealing with charts in R
  • R-bloggers is a aggregator that brings together hundreds of blogs on R, including this one. I highly recommend subscribing to their RSS feed to keep up with the latest. 
  • - it seems obvious.....but google is your best friend.  Getting a weird error message? Try copying and pasting it into google.  Chances aRe that hundreds of other people have had the same error and you might find some help.  
  • Can't figure out your problem on the google?  Reach out to the R user community. Caveat: Power R users, especially the developers, are among smartest people I have ever been in contact with.  They are active in the community and they can answer your questions!  And they will, within minutes or hours, but only if you ask the question in the correct way.  For instance, if you say "omg....why am I getting this error" may only hear crickets.  If you instead distill the problem down to its simplest form, ideally with a self-contained example, you are very likely to have your problem solved.  It takes some effort to formulate your question clearly, and often you figure out what went wrong in the process. 
    • Stack Overflow - there is an extremely active R user base on Stack Overflow.  Questions get answered very quickly...and users can vote on the best answer, so you can avoid wading through unhelpful answers (in the event there are any). 
    • You can also try emailing the R help mailing list. This is another very active community which includes many of the core developers of R.  For best results -- especially on this mailing list -- try not to submit poorly formulated questions. It helps to read their posting guide first. 

Below are links to five of the R books that I have gotten the most out of over the years.  These are all across the spectrum.....from aimed at the total beginner, to covering more specialized and advanced topics.  Have I left off your favorite R book?  Let me know in the comments. 

Introductory Statistics with R (Statistics and Computing)
This book provides a good introduction to basic statistical
concepts with an emphasis on how to do the analyses in R.
A good place to start for a beginner with little stats knowledge.
R For Dummies
Another good entry point for a complete beginner.  This book
has the typical "straight-talk" tone of the dummies series.
If you like other books in this series this might be for you.
The R Book
Now in its second edition, Crawley's R book is a must for
serious users of R for heavy-duty statistical analysis.  Includes
exhaustive coverage of base graphics, as well as great chapters
on the art of linear modeling.  Not a particularly fun read...but
an important reference. Also doubles as a door stop. 
ggplot2: Elegant Graphics for Data Analysis (Use R!)
ggplot2 is revolutionizing graphics in R. This book is really
important for understanding how the concept of the ggplot2
package differs from base graphics in R.  It is a totally different
world, and this book really helps you understand that. 
The Art of R Programming: A Tour of Statistical Software Design
So you want to go beyond merely doing statistical tests, and take
advantage of R's rich features as a programming language?  This
book is for you. It will help you understand how to unlock the
power of R to do heavy lifting.

Shameless commerce disclosure: if you purchase one of these books through one of the above links, I will receive a small referral fee from amazon.