Tips for speeding up R with byte compilation

July 29, 2013

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

A byte-compiler for R code — which can improve the execution performance of R functions — was introduced in R 2.13.0, and was automatically applied to the bundled packages in R 2.14.0. Drew Dimmery provides some good advice for identifying targets amongst your own R functions for compilation:

I have some function that will be repeatedly executed n times. You’ll want to make n large enough that it takes some fairly significant chunk of time — like maybe 20 seconds or so. You will very likely see an improvement through compilation. The first replicate will be faster when uncompiled, but every subsequent iteration will tend to be faster through compilation. If you’re using a lot of external functions in this test function, don’t expect miraculous speed increases.

Drew also provides instructions to set environment variables for R to automatically compile packages at the highest level of optimization, which you can find at the link below.

Drew Dimmery: JIT compilation in R (via Pablo Barberá)

To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


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)