Downloading and Installing R

The contents of this tutorial is geared toward downloading and installing R the statistical programming language on:

Click one of the above links to be taken to the appropriate installation section.

What is R?

Before downloading or installing any software, it may help to have a bit of a background as to what you are obtaining. Thus, let’s briefly look at “What is R?”

R is:

  • a language designed specifically for statistical computing and graphics
  • an interactive interface to many different tools.
  • based on the S language, which was developed by Bell laboratories in the late 1970s.
  • an open source (e.g. free) project that is cross platform (macOS, Windows, and Linux)
  • available on The R Project for Statistical Computing website http://www.r-project.org.

Downloading and Installation of R

The R project offers a distributed content delivery network at https://cloud.r-project.org/ that allows for the R installer to be downloaded geographically nearest to where you live. Within this site, there are also additional resources. I’ve summarized the key points of these resources below.

Windows

The R for Windows installer is available here: https://cloud.r-project.org/bin/windows/base/

Insert screenshots when R 3.4.1 is released on June 20th

macOS

The macOS installer for R is obtainable here: https://cloud.r-project.org/bin/macosx/

Insert screenshots when R 3.4.1 is released on June 20th

Linux

Depending on the Linux distribution being used, there are slightly different sets of commands required to download and install R via the command line.

Instructions for each Linux distribution with official R support are given at: https://cloud.r-project.org/bin/linux/.

Ubuntu

Official instructions: https://cloud.r-project.org/bin/linux/ubuntu/

# Extract OS distribution codename
DISTRIBUTION_CODENAME=`grep DISTRIB_CODENAME /etc/lsb-release | cut -c 18-`

# Appends the CRAN repository to your sources.list file 
sudo sh -c 'echo "deb https://cloud.r-project.org/bin/linux/ubuntu $DISTRIBUTION_CODENAME" >> /etc/apt/sources.list'

# Add GPG key of Michael Rutter the Ubuntu archives CRAN maintainer 
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9

sudo apt-get update
sudo apt-get install r-base r-base-dev

N.B. Many R packages can be installed and managed by apt-get instead of install.packages(). R packages are available under the name r-cran-*. If opting for this route, make sure to install with dependencies using:

sudo apt-get build-dep r-cran-pkgname

Debian

Official instructions: https://cloud.r-project.org/bin/linux/debian/

See the supported branch discussion regarding the necessary R repositories.

# Repository for jessie 
deb http://cloud.r-project.org/bin/linux/debian jessie-cran34/

# Use multithreaded basic linear algebra subprogram
sudo apt-get install libatlas3-base
# Install R and R dev
sudo apt-get install r-base r-base-dev

Redhat / CentOS

Official instructions: https://cloud.r-project.org/bin/linux/redhat/

To use R with RedHat distributions, you will need to add an additional repository of packages known as the Extra Packages for Enterprise Linux (EPEL).

Instructions for adding the repository can be found here: https://fedoraproject.org/wiki/EPEL/FAQ#How_can_I_install_the_packages_from_the_EPEL_software_repository.3F

## Obtain the correct version of EPEL for the RHEL system. 
## RHEL5
# su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm'

## RHEL6
# su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm'

## RHEL7
# su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm'

sudo yum update
sudo yum install R

SUSE

Official instructions: https://cloud.r-project.org/bin/linux/suse

One-click installers are available here: https://cloud.r-project.org/bin/linux/suse/#org0e4e334

Otherwise, the following terminal commands will suffice:

# Set the correct repository for SUSE version
VERSION=$(grep VERSION /etc/SuSE-release | sed -e 's/VERSION = //')
zypper addrepo -f \ 
http://download.opensuse.org/repositories/devel\:/languages\:/R\:/patched/openSUSE_$VERSION/ \
R-base

# Install R
zypper install R-base R-base-devel

# Update R when new versions are released
zypper update R-base
comments powered by Disqus