Skip to content

Install R from Source#

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

We recommend installing R from precompiled binaries instead, following these steps.

Install required dependencies#

First follow the steps to enable the required and optional repositories, as listed here.

Next, install the build dependencies for R:

$ sudo yum-builddep R
$ sudo apt-get build-dep r-base
$ sudo zypper install \
    gcc \
    gcc-c++ \
    gcc-fortran \
    readline-devel \
    xorg-x11-devel \
    liblzma5 \
    xz-devel \
    pcre-devel \
    libcurl-devel \

Specify R version#

Define the version of R that you want to install:


$ export R_VERSION=4.0.5
Available versions of R

Versions of R that are available include:

4.1.1, 4.1.0, 4.0.5, 4.0.4, 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

If you need to use an earlier version of R, then you will need to modify the export command shown above:


$ export R_VERSION=3.X.X

Please see the cran.r-project index for all available versions of R.

Download and extract R#

Download and extract the version of R that you want to install:


$ curl -O${R_VERSION}.tar.gz
$ tar -xzvf R-${R_VERSION}.tar.gz
$ cd R-${R_VERSION}


If you need to use R version 3.X.X, then replace R-4 with R-3 in the curl command listed above.

Build and install R#

Build and install R by running the following commands:


$ ./configure \
    --prefix=/opt/R/${R_VERSION} \
    --enable-memory-profiling \
    --enable-R-shlib \
    --with-blas \

$ make
$ sudo make install

Verify R installation#

Test that R was successfully installed by running:


$ /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:


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