Learn R the Right Way in 5 Steps

[This article was first published on rstats – Dataquest, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

R is an increasingly popular programming language, particularly in the world of data analysis and data science. But learning R can be a frustrating challenge if you’re not sure how to approach it.

If you’ve struggled to learn R or another programming language in the past, you’re definitely not alone. And it’s not a failure on your part, or some inherent problem with the language. Usually, it’s the result of a mismatch between what’s motivating you to learn and how you’re actually learning.

This mismatch causes big problems when you’re learning any programming language, because it takes you straight to a place we like to call the cliff of boring.

learn r for data science - the cliff of boring

What is the cliff of boring? It’s the mountain of boring coding syntax and dry practice problems you’re generally asked to work through before you can get to the good stuff — the stuff you actually want to do.

Nobody signs up to learn a programming language because they love syntax. Yet many learning resources, from textbooks to online courses, are written with the idea that students need to master all of the key areas of R syntax before they can do any real work with it.

That’s where new learners tend to drop off in droves. You get excited about learning a programming language because you want to do something with it, and but then you’re immediately led to this huge wall of complicated, boring stuff that’s between you and what you actually want to be doing. It’s no surprise that lots of students give up or drop off at points along their climb up this “cliff.”

There’s no way around learning syntax, in R or any other programming language. But there is a way to avoid the cliff of boring.

It’s a shame that so many students drop off at the cliff, because R is absolutely worth learning! In fact, R has some big advantages over other language for anyone who’s interested in learning data science. Its tidyverse ecosystem makes all sorts of everyday data science tasks very straightforward. Data visualization in R can be both simple and very powerful. The online R community is one of the friendliest and most inclusive of all programming communities.

And of course, learning R can be great for your career. Data science is a fast-growing field with high average salaries (check out how much your salary could increase). Most of the top tech firms hire R coders for data-science-related job roles. R is in use at companies across the globe, in virtually every industry that does analytics. It’s even used at the New York Times. So how can you avoid that cliff of boring and learn R the right way?

1. Find Your Motivation for Learning R

Before you crack a textbook, sign up for a learning platform, or click play on your first tutorial video, spend some time to really think about why you want to learn R, and what you’d like to do with it. What kinds of data are you interested in working with? What sorts of projects would you enjoy building? What types of questions do you want to answer?

Your aim should be to find something that motivates you in the process. This will help you define your end goal, and it will help you get to that end goal without boredom.

Try to go deeper than “becoming a data scientist.” There are all kinds of data scientists who work on a huge variety of problems and projects. Are you interested in analyzing language? Computer vision? Predicting the stock market? Digging deep into sports statistics? What’s the thing you want to do with your new skills that’s going to keep you motivated as you work to learn R?

Pick one or two things that interest you and that you’re willing to stick with. You’ll be gearing your learning towards them and building projects with them in mind.

Just be sure to pick things you’re actually interested in. This won’t work if you pick computer vision because you’ve heard it pays well, but you’re not actually interested in doing that work. Your interest is what’s going to motivate you to keep going, so it has to be genuine.

learning r - the hills of less boring

You can’t totally avoid the learning syntax “cliff of boring”, but you can make it into a much more manageable “hill of boring.”

2. Learn the Basic Syntax

Unfortunately, there’s no way to completely avoid this step. Syntax is a programming language is even more important than syntax in human language. If someone says “I’m the store going to,” their English-language syntax is wrong, but you can probably still understand what they mean. Unfortunately, computers are far less forgiving when they interpret your code.

However, learning rote syntax is boring, so your goal must be to spend as little time as possible doing rote syntax learning, and instead learn as much of the syntax as you can while working on real-world problems that interest you so that there’s something to keep you motivated even though the syntax itself isn’t all that exciting.

Here are some resources for learning the basics of R:

  • Codecademy — does a good job of teaching basic syntax.
  • Dataquest: Introduction to R Programming — We built Dataquest to help data science students avoid the cliff of boring by integrating real-world data and real data science problems right off the bat. We think learning the syntax in the context of working on real problems makes it more interesting, and our interactive platform challenges you to really apply what you’re learning, checking your work as you go. This course is also completely free.
  • R for Data Science — Textbook that’s available in print from O’Reilly or for free online.
  • R Style Guide — This shouldn’t be your primary learning resource but it can be a helpful reference.

We can’t emphasize enough that you should spend as little time as possible learning rote syntax. The quicker you can get to working on projects, the faster you will learn. You can always refer to a variety of resources for learning and double-checking syntax if you get stuck later. But your goal should be to spend a couple of weeks on this phase, at most.

learn-r-data-science-projects

Start working on structured data science projects as soon as you can.

3. Work on Structured Projects

Once you’ve got enough syntax under your belt, you’re ready to move on to structured projects more independently. Projects are a great way to learn, because they let you apply what you’ve already learned while generally also challenging you to learn new things and solve problems as you go. Plus, building projects will help you put together a portfolio you can show to future employers later down the line.

You probably don’t want to dive into totally unique projects just yet. You’ll get stuck a lot, and the process could be frustrating. Instead look for structured projects until you can build up a bit more experience and raise your comfort level.

If you choose to learn R with Dataquest, this is built right into our curriculum — every one of our data science courses ends with a guided project that challenges you to synthesize and apply what you’re learning. These projects provide some structure, so you’re not totally on your own, but they’re more open-ended than regular course content to allow you to experiment, synthesize your skills in new ways, and make mistakes.

If you’re not studying with Dataquest, there are plenty of other structured projects out there for you to work on. Find an R tutorial on Medium focused on a topic you’re interested in, for example, and work through it. Then, try to expand on it a little — how can you go deeper, or add a little more?

4. Build Projects on Your Own

Once you’ve finished some structured projects, you’re probably ready to move on to the next stage of learning R: doing your own unique data science projects. It’s hard to know how much you’ve really learned until you step out and try to do something by yourself. Working on unique projects that interest you will give you a great idea not only of how far you’ve come but also of what you might want to learn next.

And although you’ll be building your own project, you won’t be working alone. You’ll still be referring to resources for help and learning new techniques and approaches as you work. With R in particular, you may find that there’s a package dedicated to helping with the exact sort of project you’re working on, so taking on a new project sometimes also means you’re learning a new R package.

What do you do if you get stuck? Do what the pros do, and ask for help! Here are some great resources for finding help with your R projects:

  • StackOverflow — Whatever your question is, it has probably been asked here before, and if it hasn’t, you can ask it yourself. You can find questions tagged with R here.
  • Google — Believe it or not, this is probably the most commonly-used tool of every experienced programmer. When you encounter an error that you don’t understand, a quick Google search of the error message will often point you towards the answer.
  • Dataquest’s Learning Community — With a free student account you can join our learning community and ask technical questions that your fellow students or Dataquest’s data scientists can answer.

What sorts of projects should you build? As with the structured projects, these projects should be guided by the answers you came up with in step 1. Work on projects and problems that interest you. If you’re interested in climate change, for example, find some climate data to work with and start digging around for insights.

It’s best to start small rather than trying to take on a gigantic project that will never get finished. If what interests you most is a huge project, try to break it down into smaller pieces and tackle them one at a time.

Here are some ideas for projects that you can consider:

  • Expand on one of the structured projects you built before to add new features or deeper analysis.
  • Go to meetups or hook up with other R coders online and join a project that’s already underway.
  • Find an open-source package to contribute to (R has tons of great open source packages!)
  • Find an interesting project someone else made with R on Github and try to extend or expand on it. Or, find a project someone else made in another language and try to recreate it using R.
  • Read the news and look for interesting stories that might have available data you could dig into for a project.
  • Check out our list of free data sets for data science projects and see what available data inspires you to start building!

Think of the projects like a series of steps — each one should set the bar a little higher, and be a little more challenging than the one before.

5. Ramp Up the Difficulty

Working on projects is great, but if you want to learn R then you need to ensure that you keep learning. You can do a lot with just for loops, for example, but that doesn’t mean you should build 20 projects in a row that only use your for looping skills. Each project should be a little tougher and a little more complex than the previous one. Each project should challenge you to learn something you didn’t know before.

If you’re not sure exactly how to do that, here are some questions you can ask yourself to apply more complexity and difficulty to any project you’re considering:

  • Can you teach a novice how to make this project by (for example) writing a tutorial? Trying to teach something to someone else will quickly show you how well you really understand it, and it can be surprisingly challenging!
  • Can you scale up your project so that it can handle more data? A lot more data?
  • Can you improve its performance? Could it run faster?
  • Can you improve the visualization? Can you make it clearer? Can you make it interactive?
  • Can you make it predictive?

Never Stop Learning R

Learning a programming language is kind of like learning a second spoken language — you will reach a point of comfort and fluency, but you’ll never really be done learning. Even experienced data scientists who’ve been working with R for years are still learning new things, because the language itself is evolving, and new packages make new things possible all the time.

It’s important to stay curious and keep learning, but don’t forget to look back and appreciate how far you’ve come from time to time, too.

Learning R is definitely a challenge even if you take this approach. But if you can find the right motivation and keep yourself engaged with cool projects, I think anybody can reach a high level of proficiency.

We hope this guide is useful to you on your journey. Please don’t hesitate to reach out and let us know how it’s working for you!

And if you’re looking for a learning platform that integrates these lessons directly into the curriculum, you’re in luck, because we built one. Our Data Analyst in R path is an interactive course sequence that’s designed to take anyone from total beginner to job-qualified in R and SQL.

And all of our lessons are designed to keep you engaged by challenging you to solve data science problems using real-world data. The first two courses are totally free, so you have nothing to lose!

learn-r-testamonial-headshot

I needed a resource for beginners; something to walk me through the basics with clear, detailed instructions. That is exactly what I got in Dataquest’s Introduction to R course.

Because of Dataquest, I started graduate school with a strong foundation in R, which I use every day while working with data.

Ryan Quinn  Doctoral Student at Boston University

Charlie Custer

Charlie is a student of data science, and also a content marketer at Dataquest. In his free time, he’s learning to mountain bike and making videos about it.

The post Learn R the Right Way in 5 Steps appeared first on Dataquest.

To leave a comment for the author, please follow the link and comment on their blog: rstats – Dataquest.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)