Installing R in Ubuntu

Universe

The current version of R available when a new version of Ubuntu is released is always available in the universe repository. To install R:

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

This will install R, the recommended packages, and files needed to install many additional packages (but not all) from within R using install.packages("foo"). The R packages found in the universe repository are not updated when new versions of R or the recommended packages are released.

CRAN

CRAN has current versions of R and the recommended packages available for all currently supported versions of Ubuntu. Detailed instructions for adding the CRAN repositories can be found here. The first step is to add the security key:

 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 

Then you need to add the CRAN repository to end of /etc/apt/sources.list:

 deb http://cran.r-project.org/bin/linux/ubuntu precise/ 

The CRAN web address can be replaced with a local <a href="deb http:///bin/linux/ubuntu precise/”>mirror and the precise/ should be replaced with the version of Ubuntu you are using. R can then be installed:

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

The packages on CRAN are updated on a regular basis and the most recent versions will be usually be available within a couple days of their release. One advantage of using the CRAN repository is that older versions of packages are available. To install an older version of a package, it must be pinned. Directions for pinning are different for apt-get and synaptic and details can be found here.

Launchpad PPA

Packages for the CRAN repository are built on a Launchpad PPA called RutteR. It is possible to use the PPA itself, which includes a few more packages than the CRAN repository (JAGS and related packages, for example). Installing the PPA via apt is very simple:

 sudo add-apt-repository ppa:marutter/rrutter sudo apt-get update sudo apt-get install r-base r-base-dev 

The PPA is updated slightly quicker than the CRAN repository, but older packages are not available.

If you have any questions about the CRAN or PPA repositories, please email the maintainer Michael Rutter.