Install R from Binaries

These instructions describe how to install R from precompiled binaries on a Linux server.

Install required dependencies

To install the necessary runtime dependencies for R, you will need to enable additional repositories for third-party or source packages by using the following commands:

$ sudo yum install epel-release
$ sudo sed -i.bak "/^#.*deb-src.*universe$/s/^# //g" /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get install gdebi-core
$ sudo zypper --gpg-auto-import-keys addrepo https://download.opensuse.org/repositories/science/SLE_12/science.repo

Specify R version

Define the version of R that you want to install. This environment variable will be used in all of the following steps. You can install a different version of R by specifying the desired version in this step.

Terminal

$ export R_VERSION=3.6.1
Available versions of R

Versions of R that are available include:

3.6.1, 3.6.0, 3.5.3, 3.5.2, 3.5.1, 3.5.0, 3.5.0, 3.4.4, 3.4.3, 3.4.2, 3.4.1, 3.4.0, 3.3.3, 3.3.2, 3.3.1, 3.3.0, 3.2.5, 3.2.4, 3.2.3, 3.2.2, 3.2.1, 3.2.0, 3.1.3, 3.1.2, 3.1.1, 3.1.0, 3.0.3, 3.0.2, 3.0.1, 3.0.0

Download and install R

Download and install the desired version of R.

$ curl -O https://cdn.rstudio.com/r/centos-7/pkgs/R-${R_VERSION}-1-1.x86_64.rpm
$ sudo yum install R-${R_VERSION}-1-1.x86_64.rpm
$ curl -O https://cdn.rstudio.com/r/centos-6/pkgs/R-${R_VERSION}-1-1.x86_64.rpm
$ sudo yum install R-${R_VERSION}-1-1.x86_64.rpm
$ curl -O https://cdn.rstudio.com/r/ubuntu-1804/pkgs/r-${R_VERSION}_1_amd64.deb
$ sudo gdebi r-${R_VERSION}_1_amd64.deb
$ curl -O https://cdn.rstudio.com/r/ubuntu-1604/pkgs/r-${R_VERSION}_1_amd64.deb
$ sudo gdebi r-${R_VERSION}_1_amd64.deb
$ curl -O https://cdn.rstudio.com/r/opensuse-15/pkgs/R-${R_VERSION}-1-1.x86_64.rpm
$ sudo zypper --no-gpg-checks install R-${R_VERSION}-1-1.x86_64.rpm
$ curl -O https://cdn.rstudio.com/r/opensuse-42/pkgs/R-${R_VERSION}-1-1.x86_64.rpm
$ sudo zypper --no-gpg-checks install R-${R_VERSION}-1-1.x86_64.rpm

Verify R installation

Test that R was successfully installed by running:

Terminal

$ /opt/R/${R_VERSION}/bin/R --version

To ensure that R is available on the default system PATH variable, create symbolic links to the version of R that you installed:

Terminal

$ sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R
$ sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript

Install system dependencies that are used by common R packages:

$ sudo yum install \
    make \
    gcc \
    gcc-c++ \
    libcurl-devel \
    libxml2-devel \
    java-1.7.0-openjdk-devel \
    openssl-devel \
    texlive-*
$ sudo apt-get install \
    build-essential\
    libcurl4-gnutls-dev\
    openjdk-7-*\
    libxml2-dev\
    libssl-dev\
    texlive-full
$ sudo zypper install \
    make \
    gcc \
    gcc-c++ \
    libcurl-devel \
    libxml2-devel \
    java-1.7.0-openjdk-devel \
    openssl-devel \
    texlive-*

(Optional) Install multiple versions of R

If you want to install multiple versions of R on the same server, you can repeat these steps to specify, download, and install a different version of R alongside existing versions.