Skip to content

Install R#

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

Do you need to install multiple versions of R?

Our recommended installation instructions for R allow you to make multiple versions of R available, and avoid replacing existing versions of R when updating system packages.

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:

# Enable the Extra Packages for Enterprise Linux (EPEL) repository
$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

# On RHEL 8, enable the CodeReady Linux Builder repository
$ sudo subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms

# If running RHEL 8 in a public cloud, such as Amazon EC2, enable the CodeReady
# Linux Builder repository from Red Hat Update Infrastructure (RHUI) instead
$ sudo dnf install dnf-plugins-core
$ sudo dnf config-manager --set-enabled "codeready-builder-for-rhel-8-*-rpms"

# On CentOS 8, enable the PowerTools repository
$ sudo dnf install dnf-plugins-core
$ sudo dnf config-manager --set-enabled PowerTools
# Enable the Extra Packages for Enterprise Linux (EPEL) repository
$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 

# On RHEL 7, enable the Optional repository
$ sudo subscription-manager repos --enable "rhel-*-optional-rpms"

# If running RHEL 7 in a public cloud, such as Amazon EC2, enable the
# Optional repository from Red Hat Update Infrastructure (RHUI) instead
$ sudo yum install yum-utils
$ sudo yum-config-manager --enable "rhel-*-optional-rpms"
# Enable the Extra Packages for Enterprise Linux (EPEL) repository
$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm 
$ sudo apt-get update
$ sudo apt-get install gdebi-core
# Enable the python-backports repository for openblas-devel
$ VERSION="SLE_$(grep "^VERSION=" /etc/os-release | sed -e 's/VERSION=//' -e 's/"//g' -e 's/-/_/')"
$ sudo zypper --gpg-auto-import-keys addrepo https://download.opensuse.org/repositories/devel:/languages:/python:/backports/$VERSION/devel:languages:python:backports.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.3
Available versions of R

Versions of R that are available include:

4.0.3, 4.0.2, 4.0.1, 4.0.0, 3.6.3, 3.6.2, 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


R 3.3.2, 3.3.1, and 3.3.0 are unavailable for RHEL/CentOS 8, Ubuntu 20.04, Ubuntu 18.04, and SUSE 15.

Download and install R#

Download and install the desired version of R.

$ curl -O https://cdn.rstudio.com/r/centos-8/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-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-2004/pkgs/r-${R_VERSION}_1_amd64.deb
$ sudo gdebi r-${R_VERSION}_1_amd64.deb
$ 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/debian-9/pkgs/r-${R_VERSION}_1_amd64.deb
$ sudo gdebi r-${R_VERSION}_1_amd64.deb
$ curl -O https://cdn.rstudio.com/r/opensuse-152/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-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

Note

This section only applies to the first installation of R on a given system. For subsequent installations, this section should be skipped.

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

We recommend installing several optional system dependencies that are used by common R packages. Additional information about installing them is provided in our documentation.

(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.

Additional information#

Refer to the rstudio/r-builds repository on GitHub for more information on these binary distributions of R.

Follow these steps to install R from source.