7.1 Install Oracle R Distribution on Linux in a Non-Default R_HOME

The Oracle R Distribution RPMs can be installed to a directory other than the default Linux R_HOME, /usr/lib64/R.

The procedure in the following example installs the Oracle R Distribution 3.6.1 RPMs to a non-default location and still allows the user to invoke the previously installed version, R-3.3.0.

The example installs the RPMs into the directory /opt/R361. It installs the following RPMs:

R-3.6.1-1.el7.x86_64.rpm
R-core-3.6.1-1.el7.x86_64.rpm
R-devel-3.6.1-1.el7.x86_64.rpm
libRmath-3.6.1-1.el7.x86_64.rpm
libRmath-devel-3.6.1-1.el7.x86_64.rpm
libRmath-static-3.6.1-1.el7.x86_64.rpm
  1. From the directory that contains the RPMs, install the Oracle R Distribution 3.6.1 RPMs to a non-default location using the --prefix flag:

    # rpm -i *.rpm --prefix=/opt/R361

  2. Set R_HOME to the R-3.6.1 location and add $R_HOME/bin to PATH:

    # export R_HOME=/opt/R361/lib64/R

    # export PATH=$R_HOME/bin:$PATH

  3. Invoke the newly installed R-3.6.1.

    # R

    Oracle Distribution of R version 3.6.1 (--) -- "Shake and Throw"
    Copyright (C) The R Foundation for Statistical Computing
    Platform: x86_64-pc-linux-gnu (64-bit)...

If you still want to use the previous version of R, rename the default R executable /usr/bin/R to the old R version; for example, /usr/bin/R-3.3.0:

# mv /usr/bin/R /usr/bin/R-3.3.0

Now you can invoke R 3.3.0:

$ R-3.3.0
Oracle Distribution of R version 3.3.0 (--) -- "Action of the Toes"
Copyright (C) The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)...