Monday, January 3, 2022

[SOLVED] How to install R on Ubuntu 21.10

Issue

I just bought a new machine and made a fresh installation of Ubuntu 21.10 since I've read that the newer kernel works better with graphics drivers. I'm planning to update to the 22.04 LTS when it will be available. I didn't realize, however, that I might run into challenges with R.

There are plenty of questions here in SO on installing R on Ubuntu, but none seemed recent enough to address the Ubuntu version 21.10.

Ubuntu Packages For R - Full Instructions state that

As of May 19, 2021 the supported releases are

  • Hirsute Hippo (21.04, amd64 only)
  • Groovy Gorilla (20.10, amd64 only),
  • Focal Fossa (20.04; LTS and amd64 only),
  • Bionic Beaver (18.04; LTS), and
  • Xenial Xerus (16.04; LTS).

So, if I understand correctly, I have three options:

  1. Uninstall 21.10 and replace with 21.04
  2. Wait for support for 21.10
  3. Install R from source

Now, the question is, have I understood correctly, or could I use, for example, the 21.04 repository (hirsute-cran40/)?


Solution

Apparently, it is ok to use a repository of older releases.

I was encouraged by Andre Wildeberg (thanks!) and added the 21.04 repository (hirsute-cran40/) into my /etc/apt/sources.list:

deb https://cloud.r-project.org/bin/linux/ubuntu hirsute-cran40/

Then, you can follow the rest of the CRAN instructions.

Add the relevant GPG key (under "Secure APT", half way through the document):

$ 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

Finally, install R:

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

And everything should be working fine.



Answered By - teppo