How to Learn R
R is one of the most popular languages in 2020 and is widely used in finance, business, and academia. For a complete beginner, it’s possible to learn and start programming in R within a couple of weeks. Here’s how to get started.
1. Consume R content
Stack Overflow is a great resource for any aspiring data practitioner—they have the largest collection of links about R and an r-faq tag, which contains important questions and answers for learning R. Reading through these questions is a great way to learn about how to solve common tasks and avoid common pitfalls.
CRAN provides a similar FAQ resource, as well as Task Views, which list all the R packages that are used in particular areas. For example, the Finance Task View lists all the packages for Applied Finance.
For visual learners, YouTube has many great explainer videos to get you started. The R Programming 101 channel has a really enthusiastic presenter. Start with the Why you should use R video. I also like the Dynamic Data Script R series, which has a longer R Programming for Beginners tutorial.
2. Take an online course
Obviously, at DataCamp we are huge fans of online courses for learning data science! An important thing to know about R is that its functionality is split across packages. There is a core set of packages known as "base-R" developed by the R Core Team. These are included when you download R. Other packages can be created by anyone—the R ecosystem is a community driven effort. One set of packages of particular importance is called the "tidyverse." These packages are designed to work well together, and make data manipulation and visualization easier.
- Codeacademy’s Learn R is a great overview of base-R syntax. It’s available for free and is a fun overview of R for beginners.
- Coursera’s R Programming covers the basics of the R language, dives deep into challenging concepts, and uses specific examples.
- LinkedIn Learning’s Master R for Data Science path is best for learners who already have programming or data science experience.
- DataCamp uses a learn-by-doing approach that includes short videos along with hands-on coding exercises. Our R curriculum begins with a quick introduction to base-R through Introduction to R, but the majority of our curriculum is built on top of the tidyverse packages, beginning with Introduction to the Tidyverse.
R packages make it easy to create interactive visualizations and maps like this one. Source: Leaflet | OpenStreetMap contributors, CC-BY-SA
3. Set up your R environment
To work with R, we recommend installing R, RStudio, and git, and you may need to customize RStudio and your R profile as well. Watch my hands-on training for a step-by-step tutorial on how to do this.
If you prefer to follow written instructions, you can also follow the beginner guide to installing R on Windows, Mac OS X, and Ubuntu.
If you’d like to use R without installing anything, you can sign up for RStudio Cloud for free.
4. Work on R projects
There’s no substitute for hands-on experience with R using real data—you’ll probably want to build your own portfolio of data science projects.
If you’d like to download your own data and build skills in data cleaning, exploratory data analysis, and data visualizations, the R4DS Online Learning Community has a great project called Tidy Tuesday which gives you a new dataset to try analyzing each week. More experienced users may wish to download and import public datasets from Kaggle.
Of course, if you have access to real data from your company, you should use that. It’s best to work with data that you find interesting, or that matters to you in your career. Taking on a creative, open-ended challenge is the best way to gain mastery of new skills.
5. Keep on expanding your R skills
Keep building and expanding your R skills—but watch out for common pitfalls. The R Inferno by Patrick Burns is a classic text about common pitfalls and a pleasant, short read.
The R mailing lists are a good place to ask questions if you are stuck. Although email lists may feel totally antiquated now, the main benefit is that a lot of people who’ve been using R for decades are on the list to reply to you, including the R-Core team that develops R. Signing up for the R-help mailing list is a good idea if you’re serious about learning R.
As with any other language, you’ll need to practice and refine your R skills to get comfortable and become fluent. Study up on common interview questions in R programming or machine learning. Stay positive, keep at it, and you’ll be well on your way to landing a job in data science and analytics.