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 maken
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á)
This is not related to the topic and the R help forum would not answer. Can I ask if you know of material or a book that explains how to build monte carlo analysis models using R ?
Posted by: Mohan Radhakrishnan | July 30, 2013 at 02:16
Interesting. Does it also work to set the environment variable when R is running:
Sys.setenv(R_COMPILE_PKGS=TRUE)
Sys.setenv(R_ENABLE_JIT=3)
or do they really have to be set when R is started?
Posted by: Jeroen | July 30, 2013 at 06:40