Blog articles

How to Learn R - The Ultimate Guide

Updated on February 1, 2023
By Dr. Kate Blake & Brayden Ross

R is a popular programming language used mainly by statisticians and data specialists. If you found your way to this guide, you're probably curious about how R can help propel your career in data or programmming. This article will help you take a self-guided journey through learning R. We’ve compiled a list of resources for everyone from beginners to advanced learners, including a short glossary of key terms, courses, hands-on tutorials, use cases, and much more.

It's easy to find tutorials on R for beginners. It's harder to establish a roadmap in the early stages of your journey that will carry you through to self-sufficiency, including launching your career as an R programmer. That's what this guide is meant to do. If you're interested, read on. 

Learn R in 8 Steps

Should you learn R?

Learning R is a personal choice that opens up a new set of professional opportunities. In this section, you'll learn more about what R is, why you should learn it, how long it takes to learn, and how learning R changes your earning potential as a data specialist. If you're just getting started in data, now is a great time to bake in this valuable skill. 

R Logo

What is R Programming?

R is a programming language for statistical computing and analysis. It was developed in 1991 by two statisticians, Ross Ihaka and Robert Gentleman, at the University of Auckland in New Zealand. It began as an implementation of another statistical language called S, hence its name. 

In 1997, the project was expanded by the R core team, today the R Project and R Foundation.

What is R used for?

As a statistical computing language, R is primarily deployed by statisticians and data scientists for data processing, analysis, and visualization. However, R is a community-based scripting language, meaning there’s a way to complete just about any programming task. If you have an idea, there’s probably an R package for it!

Why would someone want to learn R?

In addition to its wide range of data science applications, the community-based aspect of R is a huge draw for many, as resources and help for almost any topic are easily accessible. Whether you’re a data scientist, financial analyst, or curious about coding overall, the benefits and efficiencies available to you through R’s powerful tools are numerous. 

Furthermore, R was built explicitly for statistical analysis, and as such, remains the most valuable language for statisticians today. Many tech firms prefer statisticians with R programming skills and compensation for these professionals remains high.

Should I learn Python or R?

The short answer is that you should learn both in order to maximize your career opportunities and earning potential. Both Python and R are popular programming languages for data science and machine learning. R creates powerful visualizations and has robust options for statistical analysis. Python is versatile and can be used for many tasks beyond data analysis, including developing web applications, web crawling, and deep learning models.

In LinkedIn's deep dive on Python and R, which compares earnings and popularity of the two languages, they declare Python the clear winner for professionalization. We also recommend that, as a data specialist, you learn Python, and we built a guide for that as well. However, don't give up on R just yet! As the same article also notes, many of the top companies employ data scientists with R skills, including Google, Mozilla, Merck, Novartis, and many more.

Though R and Python are both popular tools for data specialists, they differ in key ways that preserve R's value. Python is a general programming langauge that has fantastic data applications. However, R is a high-level statistical language, and it was built explicitly to deal with statistics and visualization. If you're serious about statistics, you should definitely add R to your skill set. Furthermore, it is a rarer skill. While over 58% of those learning to program in 2022 were studying Python, fewer than 6% of new learners focused on R. Because it's still the premiere language for statistics, and because you probably need to learn Python anyway, you can and should distinguish yourself by learning R. 

How much do R programmers earn?

R is very popular among statisticians and people who work with data, and it continues to be one of the most highly compensated skills for data scientists across the board. According to Stack Overflow's 2022 Developer Survey, R programmers average $67,734 a year, which is on par with some of the most popular languages including C, C++, and JavaScript. 

Is R difficult to learn?

R’s syntax is unique, and some people find that basic operations are less intuitive in R compared to other languages. Don’t let that deter you however, as there are infinite resources available to help you along your way and a huge community of programmers you can use to ask questions! 

In fact, a strong community of supportive programmers is one reason that R has maintained its popularity. We'll discuss more about how you can get involved in that community at the end of this article. 

How long does it take to learn R?

For learners with programming experience, you can become proficient in R within a couple weeks or less. Brand new programmers may take six weeks to a few months to become comfortable with the R language. Three months is generally enough time for any new programmer to use the language and start applying it in their professional life. By setting a goal with Pluralsight’s Skills app, you learn at your own pace.

6 Essential R Concepts

If you’re new to programming or data science, here are six basic terms that will help contextualize what R is and what it can do for you:  

  1. Integrated Development Environments (IDEs)
  2. Syntax
  3. R Packages
  4. Objects / Objects v. Commands
  5. The “Tidyverse”
  6. Shiny

Integrated Development Environments (IDEs)

An Integrated Development Environment (or IDE) is programming software that provides a single graphical interface. IDEs are easily accessible, intuitive, and customizable, which makes them very useful for programmers in any language. They offer features like powerful debugging, code completion, syntax checkers, and bracket matching

Most R programmers use the IDE RStudio. Here’s a sample of what it looks like:

R Studio IDE demo

Syntax

Syntax is the word for the rules that govern a programming language. It’s how the code must be written in order for it to work. As a coder, your adherence to syntax must be impeccable. Even the smallest typo will generate errors. 

While programmers do want their languages to be as natural as possible, you’ll definitely notice at first that it's different from the kind of writing you’ve been asked to do before.

> syntax <- print("In order to program, you have to learn the language's syntax!")
[1] "In order to program, you have to learn the language's syntax!"

R Packages

R Packages serve as extensions or add-ons to the R programming language. These packages are community created and can be downloaded by anyone, usually from the CRAN Repository. Packages cover an almost limitless range of tasks, and their broad availability and diversity is a major reason many programmers choose R.

Package Library in R Studio

The Package Library in RStudio

Objects / Objects v. Commands

Objects are an important part of R programming (you may hear them referenced as “variables”, but they are interchangeable). They are values that can be stored and changed by passing information to the program, allowing you to preserve the data that your program uses.

Objects v. Commands

While objects store information and data, commands aggregate, slice, visualize and create data structures, and use data structures to populate functions and help you efficiently complete tasks. An example of a command is the concatenate function, which gathers values into one cohesive unit, as shown below:

  • Concatenate is represented as c() in R, with the contents placed inside the parentheses 

  • To define an object, use <- as shown below

> statement <- c("Hello", "world!")
> print(statement)
[1] "Hello"  "world!"

The "Tidyverse"

The tidyverse contains some R’s most useful packages for data science. According to the Tidyverse website: “The tidyverse is an opinionated collection of R packages designed for data science. All packages share an underlying design philosophy, grammar, and data structures.” 

Understanding the tidyverse packages will help you become an expert in R much quicker! You can find cheat sheet guides for some of the most used packages in the Tidyverse. Refer to these often as you begin to learn R, as they provide quick reference to some of the most common commands, functions and syntax.

These Pluralsight guides can also help you prepare your data for analysis:

Tidyverse packages (readr, tidyr, dplyr, broom, %>%, ggplot2, ggmap, linear models, markdown)

Tidyverse Packages 
Source: Teach Data Science

Shiny

Shiny is a great way to share and explore your data and code through web apps. Shiny contains extensions that make your R code work with CSS, HTML, and JavaScript. Shiny’s website states, “You can host standalone apps on a webpage or embed them in R Markdown documents or build dashboards.”

 Explore more with Shiny in the Pluralsight Course, Building Your First R Shiny 1 Application.

3 Important Use Cases for R

As we indicated earlier, R was developed specifically for statistical analysis and is primarily used by data scientists. Let’s look more closely at three important use cases for R:

  1. R for Data Science

  2. Machine Learning with R

  3. Shiny Web Applications in R

R for data science

Data scientists can use spreadsheets or query languages to wrangle data, but there’s a few good reasons to prefer R. Not only do R packages provide a wide range of cleaning tools, if you’re a data scientist, you probably plan to commit your data to complex operations, and this is where R really excels. R makes it easy to work with distributions, random variables, p-values, confidence intervals, and much more.

Check out Pluralsight’s blog for tips about using R’s data science tools in the real world:

R uses cases flow chart

Machine Learning with R

When you’re teaching a computer to identify patterns, you need to feed it large quantities of exceptionally clean data. You’ll also need to test different algorithms to identify those that work best for your project. R allows you to do all of these things in the same program, and to repeat those processes later once you’ve perfected your model. 

Check out these guides and blog posts from Pluralsight for more about machine learning: 

Shiny Web Applications in R

Shiny is an R feature that allows you to create dynamic web apps that can be embedded in websites, markdowns and many other places! If you want to have a chart that displays dynamic information based on user input preferences, then you can! 

Say for instance you want to have a chart showing the sales quotas by team across Europe: you can include a Shiny App that allows a user to select which team they want to visualize the sales quotas for with the click of a mouse!

Check out these Pluralsight courses on building Shiny Apps!:

Downloading R & Exploring Essential Resources

Here are a few other resources that will help you get started on your R programming path:

Download R

Before you can use R, you’ll need to install it on your computer. Visit the Comprehensive R Archive Network (CRAN) and find your operating system in the list to download the latest version.

Download R Studio

If you’ve downloaded R and you’re ready to try out your first R project, you’ll probably want to use an IDE (Integrated Development Environment). IDEs make it easier to both write and debug your code as well as download popular packages. The most popular IDE for R is RStudio, which you can download here

This Pluralsight course will help you get set up in RStudio: Building your First R 3 Analytics Solution

You might find this guide helpful as well: How to Import Data in Rstudio

Measure your Skill IQ

If you’ve already started practicing R and want to know how your skills stack up against other programmers, then try measuring your Skill IQ on Pluralsight. This feature is for Pluralsight subscribers, so consider starting a trial if you want to access it today. 

R has several Skill IQ tests, but you might start with Data Wrangling with R. You’ll get two chances in case you don’t like your first score.

Stack Overflow

Stack Overflow is a tool used throughout the tech workforce. It is an open space to ask questions, collaborate and learn from others in any tech discipline. 

Utilizing stack overflow is going to be a key aspect of your programming journey, both in seeking answers to questions and discovering crucial tips and tricks.

To learn more, check out this Pluralsight Course on Using Stack Overflow

Are you ready to learn R?

Ready to start learning? Pluralsight has a huge catalog of R programming courses for everyone from absolute beginners to seasoned experts. Our resources include video lectures, tutorials, and hands-on learning projects:

Beginner R Courses

We recommend launching your R education with Pluralsight’s Programming with R course. This path comprises four courses to help jumpstart your coding adventure. You can also check some of our individual beginner courses below.

Advanced R Courses

For those who already have some experience coding in R. Browse our online course library for more:

Try a Hands-on R Tutorial

All of Pluralsight’s courses include exercises and code that you can follow along with on your own computer. There are also tons of free tutorials online for learning and practice with R. If you’re a hands-on learner, you could also try one of these labs on data analysis topics from Pluralsight:

Best Practices for R Programming

Throughout your programming journey, you will find that it’s easy to pick up less than desirable programming habits. To help you learn to code in a repeatable, understandable and team-friendly manner, we’ve identified some best practices for R programming:

  1. Github/Version Control

  2. Commenting Your Code

  3. Keep Your Style Consistent

Github/Version Control

Github logo

As you learn to program, you’ll accumulate a large amount of code you’ve written. You may even go back to reference methods you’ve used in the past in future work! To ensure you have all of your work in a centralized location, you should use Git - a version control software for code/files. 

Github allows you to create repositories to organize your work and access it remotely. Github also allows you to view and even revert to previous versions of your code should you wish to reverse any changes. Frequently committing and storing code in your github repositories will ensure you never lose any of your hard work! 

Check out these Pluralsight Courses to learn Git + Github:

How Git Works
Github: Getting Started

Commenting your code

Commenting allows others (and yourself) to understand the process behind each piece of code. Many times you’ll be grateful you commented on your code as you refer back to methods you may not have used in a while to quickly understand their function and purpose. A commented line of code is shown below:

> # The code below prints “Hello World!” into the console when run
> print("Hello World!")
[1] "Hello World!"

As you become more proficient in programming, you’ll begin to write code intuitively without need for many reference guides or outside resources. Still, it is always in your best interest to comment out all the code you write.

Keep your style consistent

In programming, you’ll develop your own style of coding! Your style will be apparent in naming conventions, indentation, organizational structure and many other aspects. 

It's important to keep these characteristics consistent throughout your code, so that you and others (if you’re in a team setting) can understand your code intuitively without having to decipher new naming conventions or structures. 

Google even has a widely used style guide available for R users. Explore it and take note of its principles!

R Programming FAQs

Still have burning questions about R? We’ve tried to answer a few below:

Advanced Guides & the R Community

If you're looking beyond courses and projects, then check out some of these other resources from Pluralsight and the broader web. 

Pick up some popular R guides

Knowing what other R developers are searching for online can be a great way to expand your R knowledge even as a beginner. It can give you a head start to identifying the more advanced and useful applications of the language. Here are a few of Pluralsight’s most accessed R topics.

Ridge Regression in R

“Machine learning is used by many organizations to identify and solve business problems. The two types of supervised machine learning algorithms are classification and regression. This guide will focus on regression models that predict a continuous outcome. You'll learn how to implement linear and regularized regression models using R….”

Linear, Lasso, and Ridge Regression with R

How to Forecast in RStudio

“In this guide, you will learn how to implement the following time series forecasting techniques using the statistical programming language 'R': 1. Naive Method 2. Simple Exponential Smoothing 3. Holt's Trend Method 4. ARIMA 5. TBATS…”

Time Series Forecasting Using R


Normalizing Data with R

“One way to turn an average machine learning model into a good one is through the statistical technique of normalizing data. If we don't normalize the data, the machine learning algorithm will be dominated by the variables that use a larger scale…”

Normalizing Data with R

Rpart in R

“Rpart is a powerful machine learning library in R that is used for building classification and regression trees. This library implements recursive partitioning and is very easy to use. In this guide, you will learn how to work with the rpart library in R….”

Explore R Libraries: Rpart

Meet other developers

Don’t be shy when it comes to joining the programming community. Connecting with other developers can be a great way to find helpful resources for problem solving. Here are a few places that developers can meet each other:

Kaggle Machine Learning competitions

Kaggle is a Machine Learning Competition website that allows real-world companies to structure machine learning problems in a competitive setting for monetary prizes. Each Kaggle competition is a great way to sink your teeth into machine learning in R. You can learn from other programmers, discuss ideas, and gain real-world experience with large datasets.

Get a job with R programming

OK so you've mastered R and even completed a few of your own projects. Now you want to launch (or re-launch) your data career using your new found skills. Congratulations! Here's how you can get started. 

Build an R programming portfolio

The first step to being career-ready with R is building a portfolio of your projects. But don't worry! These don't have to be projects you were commissioned for. Personal projects are great as long as they have real-world utility. There are a ton of resources out there with ideas for portfolio builders, including this list of 16 project ideas from the University of Washington. 

Aim for at least three projects that show how you would use R to solve problems in the real-world. Don't trap yourself by trying to be completely original. Just make sure the problem you are addressing is genuine, and that your solution demonstrates your proficiency with popular R packages like those in the Tidyverse

In order to launch your own project, you're going to need some data. Kaggle is a great repository for open-source data sets. Tableau has also compiled a fantastic list of data sets that you can use. Luckily, as you'll see when you peruse these options, a lot of open-source data sets come from government or non-profit entities, and the insights you can find in them have clear real-world value.

To summarize, make sure your portfolio has 

  • at least three projects
  • explains a real-world issue/question you were trying to solve/answer and the steps you took to get there
  • demonstrates your proficiency with popular R packages
  • demonstrates your ability to clean and process data for use in compelling visualizations

Prepare your resume

In addition to building a portfolio, there's a few things you want to add to your resume as well:

  • Be sure to not only list R underneath your skills, but also data analysis, data munging, and visualization.
  • Don't forget soft skills! Have you used data to tell a story? Then make sure to include "storytelling" in your skills section. Are you able to bring clarity to your findings through presentations? Then include "presentation" and "communication skills." 
  • If you've been able to build relationships with other R programmers, and if you've shared your work with the community, consider reaching out to someone for a reference.
  • Make sure your portfolio is linked to a Github account and include your Github profile on your website so that people can explore your code.
  • Remember that employers are probably more interested in higher-level tools that you've used in the past, including management tools like SharePoint or XML as well as popular computational tools like Excel or Tableau. Don't fill your skill section with R packages. Instead, include popular software that you're familiar with (and that you think you might use on a day-to-day basis in a professional setting) and let your portfolio demonstrate your proficiency in specific packages. 
  • Don't list technical skills you don't have. Instead, let an interviewer ask about particular skills, and then explain what you do know about that area, how you would learn more, and redirect them to a related skill you feel strong in. 

Search for jobs by programming language

A lot of job boards will help you find employers looking for particularly programming language skills. Here are a few to help you get started:

Search for jobs by specialization

If you would prefer to look for a particular kind of job, you can also inquire by job type. Here are a few of the most popular jobs for people who have R programming skills:

  • Statistical programmer
  • Research programmer
  • R programmer
  • Data analyst
  • Data scientist
  • Software engineer

Meet Our Authors

Profile of Brayden Ross

Brayden Ross

Brayden Ross is a Data Scientist and Pluralsight Author with years of experience promoting and teaching the skills and value behind data science and analytics. Since 2018 Brayden has helped create and direct analytics program curriculum in higher education, published articles, and given keynotes shared internationally among universities and data professionals. 

Brayden’s career has led him to drive key organizational changes using cutting edge analytics tools and big data at large-scale companies. His insights and analytics work have influenced the use of big data at over 50 colleges nationwide and were key in aiding institutions shifting to online workspaces during the COVID-19 pandemic. 

Brayden is professionally experienced in a large tech stack, ranging from cloud computing and virtual machines to graphic design and UI/UX. His focuses include programming in R, machine learning, data science, cloud computing and data visualization.

Profile of Dr. Katherine Blake

Dr. Kate Blake

Dr. Kate Blake is a writer with a penchant for technical material, including computer programming and the history of science and technology. Though she has been coding since she was twelve, her professional background is in academia, and she recieved her PhD from Indiana University in English in 2017 and worked as an English Professor for several years while publishing research on a variety of topics,

Since leaving academia, she now works in technology education. She is currently employed at Pluralsight as an SEO analyst, where she's able to combine her love of programming languages with her background in writing and education.