How to Learn R
Does being able to analyze large data sets interest you? If that’s the case, then learning R is a useful skill to have in your tool belt.
R is a popular programming language used for a wide range of purposes in data science and analysis. The R programming language provides a range of statistical and graphical tools for data analysts.
The R programming language has a wide range of use cases. R is used to analyze small data sets about stock prices. It is used to perform large-scale analyzes of data collected on social networks. This flexibility makes R a highly-favored skill among data scientists.
But how do you get started learning how to code in R? That’s the question this guide is going to answer. We’ll break down a few top tips to help you start your journey to learning R free, and on a good footing.
What Is R?
R is a programming language and environment for mathematical and statistical computing. The language was developed at Bell Laboratories by John Chambers and a team of colleagues. R is often considered to be a newer implementation of another data science language, S.
The R programming language allows you to perform statistical analysis on data sets, such as through using linear modeling, time-series analysis, classification, and more. R language was written with design in mind. This means the features you need to analyze a data set should be easy to access and use.
Why Should You Learn R?
Unlike other languages such as Python and Java, R is renowned for having a steep learning curve. But don’t let that put you off learning how to code in R. There are still plenty of reasons why learning R is a great investment.
R is built for data science
The R programming language, unlike Python, was built specifically to support mathematical calculations and data analysis.
R is widely used by data scientists around the world and with good reason. Almost all the features data scientists need are available with R. According to a survey by O’Reilly Media conducted in 2014, R is the most popular programming language used by data science professionals.
The R programming language allows you to run data science calculations without any compiler, which makes the development of code more efficient. Also, R is a statistical language, so it’s easy to convert statistical models into code using R.
R has a supportive developer community
As data has become an increasingly important part of the tech industry, the data science field has grown commensurately. According to StackOverflow, R is one of the fastest-growing programming languages in the world, which shows how widespread this technology is.
Because R is so popular, it’s easy to find other developers to help with the issues you are facing. The R language is also well documented. There are already thousands of questions on sites like StackOverflow about R. This means that you should have no trouble finding a solution to a problem.
R is used in industry
R is not just a language used by hobbyists for data analysis, it is the tool the big players are using in industry. R is used for machine learning, people learning, deep learning, statistical programming, and business analytics.
For instance, Facebook uses R for behavior analysis related to status updates. Google uses R to measure the effectiveness of its advertising campaigns.
Microsoft acquired the Revolution R company and has also used R throughout its organization. Bing, Merck, TechCrunch, and Mozilla are just a few more of many names that use R.
According to Indeed.com, as of May 4, there are 4,072 jobs in the United States for the query “R Data Scientist”. This number will likely only represent a few jobs requiring R because having skills in the language is crucial in data science roles.
What is R Used For?
R is a programming language used for statistical programming and graphics. It is commonly used in data science to process large amounts of data, identify trends, and visualize that data. R is used in a range of settings, from healthcare to technology.
In addition to making it easy to perform statistical calculations, R provides a range of tools for sharing data. It’s easy to export data from R into graphical forms that explain a dataset.
There’s no escaping the influence of R in industry. Academia uses R more than any other setting according to StackOverflow. This is closely folowed by the healthcare industry. Behind healthcare, the government, consulting insutry, and insurance industries all heavily use R.
How Long Does it Take to Learn R?
It takes around one month to learn the basics of R, assuming you spend an hour a day devoted to your studies. If you want to use R in a professional environment, you can expect to spend at least six months developing the knowledge you need.
Like any programming language, it’s hard to estimate how long it will take you to learn it. R is very different from many programming languages. While a technical background will help you, even beginner concepts will be unfamiliar to a lot of programmers.
What’s more is that there are thousands of packages out there that extend upon R. These packages are written to apply R in various specific contexts. You can expect to spend months learning how to use some of the bigger packages.
Is R Hard to Learn?
R is known for being hard to learn. This is in large part because R is so different to many programming languages. The syntax of R, unlike languages like Python, is very difficult to read.
What’s more, basic operations like selecting, naming and renaming variables in R are more confusing than they are in other languages.
If you are already familiar with basic data science principles, you’ll probably encounter a little bit of friction as you start learning R.
Over time, you’ll become more familiar with the rules of the language. This is the case for all programming skills. At first, you’ve got a long journey ahead. Once you’ve mastered the basics, you have the knowledge and mindset you need to explore more difficult concepts.
The Best Way to Learn R Fast
The question you may have now is: How do you learn R fast? To answer this, we’re going to break our question down into two parts. We’ll discuss the core skills you need to master R and the resources you can use to build those skills.
Establish Your Motivation
Before you even start learning R, you should ask yourself: What is your motivation? It can be useful to have a clear idea in your mind of why you want to learn R. This will make it more difficult to give up when you encounter a challenge.
Do you want to analyze some personal data? Or do you want to become a data scientist? Or do you just enjoy working with datasets and want a challenge? Whatever your motivation, try to make it clear and specific. If you want to become a data scientist, ask yourself what you want to analyze. Do you want to analyze stock market data, or healthcare data, or sports data?
Once you’ve established your motivation, you will be ready to continue on your journey to learning how to code in R.
Learning the Basics
You’ve decided to learn R. Your main focus should be on mastering the basics. This will give you a solid foundation upon which you can build your skills. To help you get started, we’ll break down a list of the top skills you should learn.
Syntax and Variables
There’s no escaping learning the syntax for R—the rules that govern the language—even though it is notoriously complex to learn. The good news, however, is that once you’ve learned the syntax for R, you will not have to learn it again!
After learning the basic syntax of R, you can go on to explore variables and data types. Here are the main syntactical topics you should cover:
- How to perform mathematical calculations
- Data types
- Variables and vectors
- Comparison and logical operators
- Importing functions
Data frames are objects that store data in a table structure with rows and columns. Think about a data frame like a spreadsheet, but one that can be more highly customized.
The main topics you should learn about related to data frames are:
- What is a data frame?
- How to work with CSVs in R
- How to save data to a CSV
- How to inspect a data frame
- How to select and exclude columns and rows
- How to arrange rows
Data Cleaning and Visualization
Data cleaning refers to the process of preparing a dataset for analysis. To clean a dataset, you need to remove any data that is not useful for your target use case.
Visualization is a technique used to turn the raw data with which you are working into charts. These charts showcase your data visually. Here are the main topics you should cover in these two fields:
- How to tidy/clean data
- Reshaping data and removing duplicate values
- Splitting a dataset by index and character
- Parsing strings
- How to use ggplot2 to create visualizations
- Aesthetics for data visualization
- Adding labels to a data visualization
Statistics with R
R offers a wide range of features to perform statistical analysis on a data set. So, whether you want to calculate the median of a range of data, or perform a standard deviation calculation, R has you covered. Here are a few of the main statistical concepts you should learn about:
- Mean, median, mode, and range in R
- Variance and standard deviations
- Quartiles and inter-quartile ranges
Data analysts develop hypotheses—proposed explanations for a trend—then use data to figure out whether their hypothesis does or does not exist. An essential part of working as a data analyst is being able to test hypotheses. Here are the main topics you should cover to master testing hypotheses:
- Formulating a hypothesis
- Designing an experiment to prove a hypothesis
- Significance levels using p-values
- Assumptions associated with hypothesis testing
There is a lot more you can do with R. The topics we have discussed above cover the main concepts with which you need to know to get started with R.
How to Learn R Online
So far, we have discussed why you should learn R and what topics you should cover. But where can you go to actually learn these topics?
That’s a great question! There is no right answer in terms of the “best resource” for learning R. The best resource for you will depend on your learning style. Ask yourself: Do you like reading guides, or do you prefer step-by-step tutorials? Do you like online courses, or prefer interactive walkthroughs?
You may want to experiment with a few different learning formats to see what sticks. You can focus on one or two sources when you have found something you like
Online R Courses
- Cost: Free
- Audience: Beginners
Coming to us from Harvard via edX, this course will teach you how to wrangle, analyze, and visualize data in R in just a few hours a week. The course is free, but you can pay to get graded homework and a certificate of completion.
- Cost: Free
- Audience: Beginners
Microsoft’s edX offering will have you doing basic data science in less than a month. This free course also has a paid version which offers more hands-on support and a certification at the end.
- Cost: Free
- Audience: Beginners
Another month-long course, this time from Coursera. Here you’ll learn how to install R, build simple functions, and debug your R code.
- Cost: Free
- Audience: Beginners
If you have no experience in programming at all, consider this Udemy course targeted at absolute beginners.
- Cost: Free
- Audience: Beginners
With over 8 hours of recorded lectures, this Udemy offering will teach you the basics of data structures, vectors, and data frames, all key skills for new data scientists!
Online R Books
R For Data Science by Hadley Wickham
It’s hard to go wrong with a nice overview written by an O’Reilly author. At over 500 pages, this volume will introduce you to the basics of importing data, tidying it up, analyzing it, and visualizing it. With this foundation in place, you’ll be prepared to do high-quality data science with R.
Introduction To Data Science by Rafael Irizarry
While this isn’t an R tutorial per se, it will walk you through the foundational concepts in data science, such as statistical analysis, hypothesis testing, and regression models, all with examples in R.
R Packages by Hadley Wickham
Any language as old and widespread as R is going to have lots and lots of third party software packages. Getting a handle on this ecosystem is easier with an overview like this one.
Exploratory Data Analysis With R by Robert Peng
One of the most important skills for a new data scientist to learn is ‘exploratory data analysis.’ This consists of simply getting a feel for the data by inspecting them, making simple plots, and performing simple tests. This book shows you how to do that in R.
Online R Resources
Impatient R is an online tutorial aimed at those who are just starting to learn R. This tutorial covers all the key concepts you need to know, from objects to common R jargon.
Cookbook for R is a repository of solutions for common R problems. This online resource covers topics like formulas, the basics, data input and output, and creating graphs. Cookbook for R is an excellent reference guide.
R Bboggers is a community of tutorials about R. This website features hundreds of tutorials that have been written by a range of contributors. You’ll find guides covering everything from data formats to removing outliers.
Attend a Coding Bootcamp
Given the high demand for R skills in the data science field, many coding boot camps have adopted R as part of their curricula. If you are looking for a more immersive, project-focused experience, then looking into coding boot camps for data science may be worth your time.
To help you get started, check out the Career Karma boot camp directory. Our directory features a list of hundreds of coding boot camps, including many that specialize in R and data science.
Work on R Projects
Taking online courses and following tutorials will only take you so far. Once you’ve mastered the syntax—which is a great feat in itself—you’ll be ready to start working on your own projects.
Projects let you build your skills while working on a project that is meaningful to you. That’s right. When you work on a self-driven project, you get to choose what you work on and how it turns out.
Are you stuck for ideas? If that’s the case, ask yourself: What data do I generate every day? Then, try to think of a project you could build using that data. Maybe you want to analyze data from your fitness tracker. Or maybe you want to analyze your finances. Or maybe you are interested in weather trends from your local area in spring.
No matter what you end up working on, make sure it is relevant to one of your own interests. This will ensure that, even if you encounter a challenge, you’ll have no problem finding the motivation you need to keep going.
R Project Ideas
Here are a few ideas to help you out:
- Analyze the performance of the stock market
- Sentiment analysis of Amazon reviews
- Movie recommendation engine
- Analyze donations data for the U.S. 2016 Presidential election
- Analyze voting turnout data for the U.K. 2017 General Election
The first project you work on should be simple, to ensure that you don’t take on too much too soon. This is a common mistake made even by seasoned programmers who are learning a new skill). When you feel more confident, you can start adding new complexities to your projects.
If you can’t find a data set with which to work, you should check out Kaggle. Kaggle is a site for data analysts and scientists to work together and share project ideas. On Kaggle, there are thousands of open-source data sets that you can use in your projects free of charge. This almost eliminates the problem of “I can’t find the data I want!” when you’re working on a new project.
Explore More Difficult Topics
Once you’ve built a few projects, you can then go on to explore more difficult projects. This is especially important when you’re learning R because the steeper learning curve can make it easy to stop learning past a certain point. You need to keep going and challenge yourself to reach new heights.
Here are a few questions you should ask yourself to encourage you to think about how you can improve:
- Can your project handle a larger data set?
- Can you add predictive features to your project?
- What biases may exist in your analysis? How can you combat those biases?
- How can you improve the performance of your project?
- Could you generate more visualizations from your data?
These questions will help you get thinking about how you can improve even once you’ve learned the basics. Because, after all, when you’re learning to code there is no real “end”— there’s always something new you can learn.
Join an R Developer Community
Learning how to code is hard. And learning the syntax for R is its own challenge. As a result, you may encounter situations where you feel tempted to give up and do something else.
One way to help address these situations is to join a developer community. Developer communities are exactly what you think they are. They are communities of programmers who come together to share ideas and collaborate on projects with each other.
Developer communities bring together large numbers of developers, from beginners to experts, into one room to discuss coding. As a result, these communities are often great places to meet new coders and find solutions to the problems everyone is facing.
R Developer Communities
Here are a few great communities for aspiring R developers:
- RStudio Community: The RStudio community is a group of R developers and users of the RStudio package who come together to discuss R programming.
- Dev.to: Dev.to is a community of developers helping each other out. There are a number of great data science threads that can be found on Dev.to, even though their R community is new.
- StackOverflow: StackOverflow is a questions-and-answers site for programmers. Over the years, thousands of people have posted questions related to R. If you need help with something, you should be able to find an answer on StackOverflow.
- R-Help Mailing List: Mailing lists may be an old idea. The R-Help mailing list is a great place for R developers to stay up to date with the latest goings-on in the R community.
Joining a developer community is not enough, though. Once you join a community, you should start contributing as soon as possible. Volunteer to help others if you can, or ask other people useful questions to help keep discussions going.
Practice Your R Skills
Practicing is the best way to become an expert R developer. As the old saying goes, “practice makes perfect.”
Learning how to code is a skill, and like any skill, practicing is the best way to get ahead. With R, practice is especially important because many of the syntax features you will encounter can be difficult to understand at first. But, as you get more practice working with R, you’ll adapt to the quirks of the language.
Are you looking for ways to practice your R skills? Here are a few suggestions for how you can do so:
- Build a project that interests you. Working on a project requires a big commitment. It is worth it because once you start you’ll not want to give up until you are done.
- Participate in coding challenges. Sites like Coderbyte and Codewars feature coding challenges specific to R that you can use to build your skills.
- Analyze datasets for fun. If you have a spare few hours, don’t hesitate to go onto Kaggle, read over a challenge, and give it a go.
We cannot emphasize the importance of practicing enough. The more you practice, the better you’ll get: it’s that simple.
R is a programming language that has become increasingly popular over the last few years among data scientists and analysts. Being able to code in R not only can help you unlock career opportunities. Knowing R will also give you a whole new range of skills that you can use to analyze data. You’ll also build the mindset you need to approach problems in your life using data.
There’s no way around it—learning R is a challenge, and its syntax can be confusing even to existing programmers. And, R is constantly changing, so you may find that over time you need to come back to basic concepts and master them again. But that’s just part of being a programmer because all the best programming languages evolve over time.
Learning R is not only possible but within reach, if you follow the steps we outlined in this article. Here’s a reminder of what we recommend:
- Find learning resources
- Learn the basics
- Build a project
- Look for ways to improve your projects
- Join a developer community
- Practice your R skills
Following these steps will help make your journey to learning R more smooth. Then, once you’ve learned R, you can start working on a wide range of exciting projects—the sky’s the limit!
About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Read more