Tips on Learning R

Colleagues often ask me: “How can I learn R?”  Recently, I helped teach an “Introduction to R” class for the Advanced Research Techniques Forum (http://www.marketingpower.com/Calendar/Pages/2011ARTForum.aspx). So that’s one answer.  Here’s another:

Find an R-suitable project and force yourself to use it!  R is really a programming language, not a “statistics package” … and like any programming language, you can only learn it by using it to accomplish something.

What makes a project R-suitable?  I divide that into three groups:

1. Projects that need cutting-edge or custom statistical methods. R quite simply is the tool where new methods are developed first. If you need to try the latest in Bayesian, machine learning, classification, genomics, or similar areas: do it in R.

2. Processes that benefit from R’s language and object structure. This is why I started with the S language back in 1997: I needed to run hundreds of models and extract key information from them. If you need to bootstrap a process, or compare or iterate models, R is the place.

3. Something that you know quite well.  This is where R offers little attraction, but where you can leverage your knowledge. A frequency analysis you do every day; a regression model you run every month; a chart that you can make in 5 seconds in Excel – those are great places to replicate the work in R just to force yourself up the learning curve.

Note that groups #1 and #2 are the easiest and luckiest places to be: if nothing else does what you want (except complete custom code), then R is an obvious answer.  Group #3, choosing a problem you could solve elsewhere, is the most frustrating and requires enormous discipline. You’ll be questioning R every step of the way (“why can’t I just point and click?!”) … until something clicks and you discover the answer for yourself.  OTOH, #3 is the easiest place to start from the perspective of finding specific help for your task; if it can be done easily somewhere else, then a recipe has likely been developed for R.

There are scores if not hundreds of R books that can help you. If you use R for long, eventually you’ll own a shelf of them. Meanwhile, a great first book to learn and get stuff done is Paul Teetor’s R Cookbook (http://www.amazon.com/Cookbook-OReilly-Cookbooks-Paul-Teetor/dp/0596809158). 

But again, and most importantly: Pick a problem, use R to solve it, and stay with it until you’re done. Then repeat. R undoubtedly will frustrate you. It may take hours or even days for something that seems like it should be simple. Remember that you’re learning a new language, so progress should be slow. Yet every time you go through the process (choose, use, stick with it) you’ll know more and will work faster and better. Good luck!

Leave a Comment