Get startedGet started for free

Welcome!

1. Welcome, Bienvenue, Willkommen, ??

Hi! I'm Colin Gillespie, and I'm an associate Professor at Newcastle University and also a consultant at Jumping Rivers. Welcome to the efficient R programming course.

2. Is R just slow

R has the unfortunate reputation for being slow. While it is certainly true that in a competition of raw speed with a language like C, R would come in a distant second. This is an unfair comparison to make. Instead, the total programming time is made up of three components.

3. R vs. C

Thinking, coding, and running. In many statistical analyses, we want to try multiple algorithms. Therefore, we want the thinking and coding parts to be optimized, and this is R's strength.

4. A typical R workflow

By the time we've loaded data into R, created a scatter plot and fitted a regression line, our friendly C programmer would have just launched their code editor and would be checking StackOverflow for how to read in a CSV file. We use R because it is good with statistics. However, with the advent of big data and complex statistical algorithms, we may have to optimize our code.

5. When to optimize

Before we jump straight in at the deep end, we should remember what Donald Knuth said: "premature optimization is the root of all evil". That is, only optimize when necessary. Before we finish this introduction, there is one simple optimization we should ensure we use. Keep R up-to-date.

6. R version

New versions of R rarely break code; in fact I have R code from turn of the century that still works! New versions of R often provide speed boosts, such as improved handling of data frames, so your code just goes a little bit faster. Version 2-point-13 introduced byte compiling for speeding up functions and version 3 supported large vectors. Just by upgrading, your code runs faster. Main R releases happen every April, with smaller incremental updates occurring throughout the year.

7. Let's practice!

In the following exercise, you'll see how to check which version of R you run.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.