Install R
The recommended installation instructions for R covers making multiple versions of R available, and avoid replacing existing versions of R when updating system packages.
Additionally, these instructions cover installing multiple versions of R, downloading R, creating a symlink to R, etc.
Install required dependencies
To install the necessary runtime dependencies for R, enable additional repositories for third-party or source packages by using the following commands:
Enable the Extra Packages for Enterprise Linux (EPEL) repository:
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Enable the CodeReady Linux Builder repository:
sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
# enable the CodeReady Linux Builder repository from Red Hat Update Infrastructure (RHUI)
sudo dnf install dnf-plugins-core
sudo dnf config-manager --set-enabled codeready-builder-for-rhel-9-*-rpms
Enable the Extra Packages for Enterprise Linux (EPEL) repository
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Enable the CodeReady Linux Builder repository:
sudo subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms
# enable the CodeReady Linux Builder repository from Red Hat Update Infrastructure (RHUI)
sudo dnf install dnf-plugins-core
sudo dnf config-manager --set-enabled "codeready-builder-for-rhel-8-*-rpms"
Specify R version
Consult with your R user group to determine which version/versions of R they would like installed. Once defined, set the environment variable, shown below, to the first R version they request.
The CVE-2024-27322 patched versions of R >= 4.0.0 are available via the links below. If you previously installed R from these links, reinstall to obtain a patched version. See rstudio/r-builds#219 for more details.
For multiple versions of R, follow the remaining steps and repeat them for each R version required:
export R_VERSION=4.4.1
Versions of R that are available include: 3.6.x, 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x
If you need to use an earlier version of R, then you will need to modify the export command shown above:
Terminal
export R_VERSION=3.X.X
Please see the CRAN index of R versions for all available versions of R.
Download and install R
Download and install the desired version of R.
curl -O https://cdn.rstudio.com/r/rhel-9/pkgs/R-${R_VERSION}-1-1.x86_64.rpm
sudo dnf install R-${R_VERSION}-1-1.x86_64.rpm
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/ubuntu-2404/pkgs/r-${R_VERSION}_1_amd64.deb
sudo apt-get update
sudo apt-get install ./r-${R_VERSION}_1_amd64.deb
curl -O https://cdn.rstudio.com/r/ubuntu-2204/pkgs/r-${R_VERSION}_1_amd64.deb
sudo apt-get update
sudo apt-get install ./r-${R_VERSION}_1_amd64.deb
curl -O https://cdn.rstudio.com/r/ubuntu-2004/pkgs/r-${R_VERSION}_1_amd64.deb
sudo apt-get update
sudo apt-get install ./r-${R_VERSION}_1_amd64.deb
curl -O https://cdn.rstudio.com/r/debian-12/pkgs/r-${R_VERSION}_1_amd64.deb
sudo apt-get update
sudo apt-get install ./r-${R_VERSION}_1_amd64.deb
curl -O https://cdn.rstudio.com/r/debian-11/pkgs/r-${R_VERSION}_1_amd64.deb
sudo apt-get update
sudo apt-get install ./r-${R_VERSION}_1_amd64.deb
curl -O https://cdn.rstudio.com/r/debian-10/pkgs/r-${R_VERSION}_1_amd64.deb
sudo apt-get update
sudo apt-get install ./r-${R_VERSION}_1_amd64.deb
curl -O https://cdn.rstudio.com/r/opensuse-155/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-156/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:
/opt/R/${R_VERSION}/bin/R --version
Create a symlink to R
This section only applies to the first installation of R on a given system.
Skip this section for subsequent installation.
To ensure that R is available on the default system PATH
variable, create symbolic links to the version of R that’s installed:
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
(Optional) Install recommended packages
Posit recommends installing several (optional) system dependencies used common R packages.
Posit Package Manager can automatically detect known system dependencies and provides installation commands for supported Linux operating systems. The System Dependency Detection documentation provides additional information.
(Optional) Install multiple versions of R
To install multiple versions of R on the same server, 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.
If you need to customize how R is configured. For example, installing R at a different location than /opt/R
, then follow these steps to install R from source.