1) A quick and easy way to speed up your scripts

Where possible compile your functions

 

Byte Code Compiler

cmpfun(f, options = NULL)

Options: optimize - specifies the optimization level, 0 - 3
suppressAll - if TRUE no messages will be shown
suppressUndefined - TRUE to suppress all messages about undefined variables

Example of a compiled function
library(compiler)
library(ggplot2)
library(microbenchmark)

f <- function(n, x) for (i in 1:n) x = (1 + x)^(-1)
g <- cmpfun(f)

compare <- microbenchmark(f(1000, 1), g(1000, 1), times = 1000)

autoplot(compare)