linuxr

Installing multiple versions of R


When I was in school the system administrator had multiple versions of R installed. I'm running into a bug with R-3.1.0 and need to install reinstall some past versions of R for development while this bug is investigated, but I don't see any documentation about how to have multiple concurrent versions of R on the same system ti should look something like

$ ls -l /usr/lib | grep R-
lrwxrwxrwx  1 root  root         8 Jun  3 09:41 R -> R-3.1.0/
drwxr-xr-x  9 root  root      4096 May 15 11:56 R-3.1.0
drwxr-xr-x  9 root  root      4096 May 15 11:56 R-3.0.3


$ ls -l /usr/bin | grep R-
lrwxr-xr-x  1 root  root         8 Jun  3 09:41 R -> R-3.1.0
-rwxr-xr-x  9 root  root      4096 May 15 11:56 R-3.1.0
-rwxr-xr-x  9 root  root      4096 May 15 11:56 R-3.0.3

I see no documentation about how to achieve this either in the R Installation and Administration guide or in the configure --help. I'm running a Gentoo system and the ebuild removes or overwrites the previous version of R on install, so I'll likely be installing from source.


Solution

  • Yes, this is pretty easy as Josh Ulrich's comment already says.

    People usually have this question regarding r-devel installation alongside the basic R you will get from your distro. I use a simple shell script to build / update R-devel, and two matching ones to run R-devel and Rscript-devel. I can't recall if I blogged about it, but folks seem to point to an this older post on the r-sig-debian list which contains it. Here is a nice post by Michael detailing the same process.

    And by creating new subdirectories, you can add as many R version as you want. You should keep the local builds in /usr/local, though, and could create softlinks for the binaries in /usr/local/bin. The script R itself will have R_HOME_DIR hard-coded and "just work".

    Fancier approaches involve virtualization, and on Linux your best bet is docker which I am playing with now, and which I hope to detail at some point for this very purpose of testing R packages against multiple compilers etc.