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

The Linux 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 4.0.5 RPMs to a non-default location and still allows the user to invoke the previously installed version, R-3.6.1.

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

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

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

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

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

    # export PATH=$R_HOME/bin:$PATH

  3. Invoke the newly installed R-4.0.5.

    # R

    Oracle Distribution of R version 4.0.5  (--) -- "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.6.1:

# mv /usr/bin/R /usr/bin/R-3.6.1

Now you can invoke R 3.6.1:

# R-3.2.0
Oracle Distribution of R version 3.2.0  (--) -- "Full of Ingredients"
Copyright (C)  The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)...