How can I install the newest version of R (currently 4.0.0) on CentOS?

14.7k Views Asked by At

Title pretty much says it. I have epel installed and when I try to yum the new version, I get version 3.6.0.

I know it's possible to compile it from the source, but CRAN seems to want to steer me away from that (and I'm happy to oblige).

3

There are 3 best solutions below

0
Caroline On

I was able to get R version 4.0.2 using the script on this page:

https://www.osradar.com/how-to-install-r-and-rstudio-on-centos-8/

The only problem was that the instructions to fix the path weren't working for me, so I just changed it in RStudio Server.

1
pengchy On

The default channel does not store the latest version of R. Fortunately, you can get the latest version of R through the conda-forge channel. Therefore, you should add this channel first.

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
conda config --set show_channel_urls yes
conda search R
conda install R
1
Hoter On

The RStudio documentation has a detailed tutorial on how to install almost any R version (including 4.X.X) on CentOS 7 & 8: https://docs.rstudio.com/resources/install-r/#optional-install-recommended-packages

In case the link is taken down, I detail here the steps for CentOS 7:

# 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"

# Download and install R
export R_VERSION=4.0.0
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

# Verify installation
/opt/R/${R_VERSION}/bin/R --version

# Create symlink to R
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