Welcome, Bienvenue, Willkommen, ??

Writing Efficient R Code

Colin Gillespie

Jumping Rivers & Newcastle University

Writing Efficient R Code

Writing Efficient R Code

A typical R workflow

# Load
data_set <- read.csv("dataset.csv")

# Plot plot(data_set$x, data_set$y)
# Model lm(y ~ x, data = data_set)
Writing Efficient R Code

When to optimize

Premature optimization is the root of all evil

Popularized by Donald Knuth

Writing Efficient R Code

R version

  • v2.0 Lazy loading; fast loading of data with minimal expense of system memory.
    • v2.13 Speeding up functions with the byte compiler
    • v3.0 Support for large vectors
  • Main releases every April

    • e.g., 3.0, 3.1, 3.2
  • Smaller bug fixes throughout the year

    • e.g., 3.3.0, 3.3.1, 3.3.2
Writing Efficient R Code

Let's practice!

Writing Efficient R Code

Preparing Video For Download...