Install R
Packages for the current R 4.4. release* are available for Ubuntu ‘Long Term Support’ (LTS) releases until their official (extended) end of life date. However, only the latest LTS release is fully supported. Recent releases are build for amd64 (i.e., 64-bit Intel and AMD) CPUs; older releases are also available for i386 CPUs; arm64 (i.e., M1/M2/M3, graviton etc) CPUs are not supported. As of May 1, 2024 the supported releases are
- 24.04 (“noble”, amd64 only),
- 22.04 (“jammy”, amd64 only),
- 20.04 (“focal”, amd64 only),
- 18.04 (“bionic”), and
- 16.04 (“xenial”).
Run the lines below (if as root
use the second tab
without sudo
) to tell Ubuntu about the R binaries at CRAN,
install R and its dependenciesm and set the repo up for updates. This
uses lsb_release -cs
to pick the Ubuntu flavor you run: one
of “noble”, “jammy”, “focal”, “bionic”, … Note that ‘cran40’ denotes a
binary compatibility break by the R 4.0.* release, it does not install R
4.0.* but the current R 4.4.* series.
Installation Steps
User
# update indices
sudo apt update -qq
# install two helper packages we need
sudo apt install --no-install-recommends software-properties-common dirmngr
# add the signing key (by Michael Rutter) for these repos
# To verify key, run gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# add the repo from CRAN -- lsb_release adjusts to 'noble' or 'jammy' or ... as needed
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
# install R itself
sudo apt install --no-install-recommends r-base
Root
# update indices
apt update -qq
# install two helper packages we need
apt install --no-install-recommends software-properties-common dirmngr
# add the signing key (by Michael Rutter) for these repos
# To verify key, run gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# add the repo from CRAN -- lsb_release adjusts to 'noble' or 'jammy' or ... as needed
add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
# install R itself
sudo apt install --no-install-recommends r-base
See Also
For more detailed instructions, including details on administration and maintenance of R Packages, see the full README. For older R releases, see the corresponding README.
To install all (currently twenty-one-thousand) CRAN packages (as well as several hundred BioConductor packages) as Ubuntu binaries, use r2u which builds on top of these instructions and adds an additional repository. Details on how to set it up and install packages can be found at the r2u project website.
The c2d4u project provided (parts of) CRAN as binaries for many year, but is currently on hiatus and no longer updating packages. Hence please use r2u for CRAN binaries.
Acknowledgements
The Debian R packages and the r2u project are maintained by Dirk Eddelbuettel. The Ubuntu packages are compiled by Michael Rutter (marutter@gmail.com) using scripts initially developed by Vincent Goulet. These instructions are provided by Michael and Dirk. Questions can be asked on the r-sig-debian mailing list for R on Debian, Ubuntu, and other derivative distros.