What’s the best way to learn the programming language R? (Preferably, for free)

Number crunchers.
Number crunchers.
Image: Reuters/Gabrielle Lurie
We may earn a commission from links on this page.

As data becomes an ever larger part of work, for many people spreadsheets just are not enough. Programs like Microsoft Excel and Google Sheets are powerful tools, but they have limitations in terms of the amount of data you can work with, the kind of analyses you can do, and the types of charts you can make. When data users reach these limitations, the obvious next step is learning a programming language.

And that’s when they come to me. I’ve lost count of how many times friends and colleagues have asked, “How do I go about learning R?”

When I pushed spreadsheets as far as they would go, I chose to learn the statistics-focused programming language R. Now, I do nearly all of my data work in that language, and I’ve come to love it. R is one of the two most popular programming languages used by data analysts and data scientists, along with Python. (For details about learning Python, go here).

R is free and and open source, developed in the early 1990s by statisticians in New Zealand. Today, millions of people use the language, including analysts at tech giants like Google and Facebook and journalists at the New York Times and FiveThirtyEight.

Using a programming language like R can seem daunting at first, and while there is definitely a learning curve, putting in the time is rewarded by making your work a lot easier. It is simpler to replicate tasks, while processes that used to take an hour of pointing and clicking might now just take a minute of writing code.

When people ask me how to learn R, I am never really sure what to tell them. So, I turned to an expert.

Mara Averick is a developer for the company RStudio, a company that makes the most popular interface for using R. She is also R’s most ardent advocate, highlighting material for new learners on her popular Twitter account. Averick, 34, has been using R since high school. She picked it up to study statistics that would help her win a fantasy basketball league.

When Averick gets asked how to learn R, her usual response is a question of her own: What exactly do you want to do?

For people who want to up their business-analytics game, Averick points them to the abundance of video tutorials out on the web. Her favorites are DataCamp, which has a free class taught by her colleague Hadley Wickham, the most influential developer of the R language. She also points people to popular online classes from Johns Hopkins University taught by data science luminaries Jeff Leek and Roger Peng (if you pay you can get a certificate of completion, but you can also freely audit the classes).

For aspiring data journalists, or people just wanting to do side projects now and then, Averick suggests Storybench, a resource created by Northeastern’s School of Journalism. The site, which I also recommend, gives detailed examples of how to use R code to tell a story with data. She is also a fan of the free book Hands on Programming with R, which takes a project-based approach to learning the language.

For those primarily interested in data visualization, she suggests purchasing the book Visualize This by Nathan Yau. It is a nice mashup of inspiring graphics and practical how-tos, Averick says.

“But really my number-one recommendation to people is to join a community of people learning it,” Averick says. It may come as a surprise to non-programmers, but programming-language communities can be warm, fun, and friendly. Averick says standout examples of this are the R-Ladies Meetup groups—there are 80 of them in cities across the world, in which veteran and new female R programmers get together to discuss their projects and mentor each other. Another good example is the R for Data Science Online Learning Community, a Slack group where people work through Hadley Wickham’s free online book R for Data Science (there is a separate Slack channel for each chapter).

Finally, once you get a feel for R, Averick recommends just playing around with datasets you think are cool. Data repositories like Kaggle and data.world are good places to look for data that strikes your fancy.

This, I think, is the key. There is no better way to learn R than to dive in with a dataset you feel passionate about, whether it’s about Russian Twitter trolls or New York City dog names. Taking on a creative, freeform challenge is always the best way to learn something new.