Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

There is a time for some things, and a time for all things; a time for great things, and a time for small things — Miguel de Cervantes

Building R packages from sources may take a long time, especially if they contain a lot of C/C++/Fortran code. Long compile time might be especially frustrating if you are a package developer and you need to recompile your project very often.

Here is how long it takes to compile the stringi package on my laptop (if the ICU library is also compiled from sources):

$time R CMD INSTALL ~/R/stringi --preclean --configure-args='--disable-pkg-config' # real 2m6.989s  On many R installations, the build process is set up so that only one C/C++ source file is compiled at a time: Yet, there is a simple solution for that — we may ask GNU make to allow more than one job to be submitted at once. In order to do so, we edit the /lib64/R/etc/Renviron file (where /lib64/R/etc/ is the result to a call to the R.home() function in R) and set: MAKE='make -j 8' # submit 8 jobs at once  instead of previously used settings. This significantly decreases the time needed to compile stringi : $ time R CMD INSTALL ~/R/stringi --preclean --configure-args='--disable-pkg-config'
# real    0m38.831s


Thanks to that, we may now spend the time saved to enjoy more whomever or whatever we love. 🙂