Installing multiple versions of R on Linux


Binary and Source Versions

Versions of R can be obtained by various means, the most common of which is installing a binary version from a standard apt-get (Debian/Ubuntu) or yum (RHEL) repository. Versions installed this way are nearly always located in the /usr/lib/R directory.

You may also have obtained a binary version of R from a vendor like Oracle, Revolution Analytics, or TIBCO. In those cases please consult the vendor’s documentation to determine the location where R is installed and update the relevant RStudio configuration files to point to it as described here.

To install additional versions of open-source R side-by-side with a version obtained from an apt-get or yum repository you will typically need to build R from source. The next section provides further details and recommendations on building from source.

Building Additional Versions from Source

Installing Dependencies

Installing additional versions of R side-by-side with the system version requires building R from source but is very straightforward. First, ensure that you have the build dependencies required for R. On RedHat/CentOS you’d use this command:

$ sudo yum-builddep R

On Debian/Ubuntu systems you’d use this command:

$ sudo apt-get build-dep r-base

Configuring and Building R

Once you’ve satisfied the build dependencies, you should obtain and unarchive the source tarball for the version of R you want to install.  As an example, one mirror you can download R 3.X source from is: 

Once the source is downloaded, from within the extracted source directory, execute these commands (this example assumes you are installing R 3.2.0):

$ sudo ./configure --prefix=/opt/R/3.2.0 --enable-R-shlib
$ sudo make
$ sudo make install

Note that the --enable-R-shlib option is required in order to make the underlying R shared library available to RStudio Server.

Using the System BLAS Libraries

You may also wish to link to the system BLAS libraries rather than use the R internal versions. For this you’d use the following configure command:

./configure --prefix=/opt/R/3.1.0 --enable-R-shlib --with-blas --with-lapack