Skip to main content

Writing Efficient R Code

Learn to write faster R code, discover benchmarking and profiling, and unlock the secrets of parallel programming.

Start Course for Free
4 Hours14 Videos43 Exercises35,700 Learners3100 XPBig Data TrackR Programmer TrackR Programming Track

Create Your Free Account



By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA. You confirm you are at least 16 years old (13 if you are an authorized Classrooms user).

Loved by learners at thousands of companies

Course Description

The beauty of R is that it is built for performing data analysis. The downside is that sometimes R can be slow, thereby obstructing our analysis. For this reason, it is essential to become familiar with the main techniques for speeding up your analysis, so you can reduce computational time and get insights as quickly as possible.

  1. 1

    The Art of Benchmarking


    In order to make your code go faster, you need to know how long it takes to run. This chapter introduces the idea of benchmarking your code.

    Play Chapter Now
    50 xp
    R version
    100 xp
    50 xp
    Comparing read times of CSV and RDS files
    100 xp
    Operational differences: "<-" and "="
    50 xp
    Elapsed time
    100 xp
    Relative time
    50 xp
    How good is your machine?
    50 xp
    DataCamp hardware
    100 xp
    Benchmark DataCamp's machine
    100 xp
  2. 3

    Diagnosing Problems: Code Profiling

    Profiling helps you locate the bottlenecks in your code. This chapter teaches you how to visualize the bottlenecks using the `profvis` package.

    Play Chapter Now

In the following tracks

Big DataR ProgrammerR Programming


tommyjeeTom JeonrichieRichie Cotton


Intermediate R
Colin Gillespie Headshot

Colin Gillespie

Assoc Prof at Newcastle University, Consultant at Jumping Rivers

Colin is the author of Efficient R Programming, published by O'Reilly media. He is an Associate Professor of Statistics at Newcastle University, UK and regularly works with Jumping Rivers to provide data science training and consultancy. He is the only person in history to move to Newcastle for better weather.
See More

What do other learners have to say?

I've used other sites—Coursera, Udacity, things like that—but DataCamp's been the one that I've stuck with.

Devon Edwards Joseph
Lloyds Banking Group

DataCamp is the top resource I recommend for learning data science.

Louis Maiden
Harvard Business School

DataCamp is by far my favorite website to learn from.

Ronald Bowers
Decision Science Analytics, USAA