+3 votes
in Operating Systems by (6.5k points)

I tried to install R on Ubuntu 20.04 using the following command:

sudo apt-get install r-base

Although it worked, it did not install the latest version of R. It installed R 3.6 instead of R 4.1.
How can I install the latest version?

1 Answer

0 votes
by (35.8k points)

The Ubuntu repository does not have the latest version of R, so it installed the old version.

If you want to install the latest version of R, you need to update your apt source.list file.

Here are the steps:

1. Since you are installing R on Ubuntu 20, edit the file /etc/apt/sources.list and add the following line. For other versions of Ubuntu, check the list here.

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

2. Add the key to your system using the following command. Without adding the key, it will not fetch the latest version from CRAN.

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

3. If steps 1 and 2 did not fail, you are all set to install the latest version. To install the complete R system, use the following commands:

sudo apt-get update

sudo apt-get install r-base

Your computer will now have the latest version of R.

Related questions

+3 votes
1 answer
+4 votes
1 answer
+2 votes
1 answer
+2 votes
1 answer
...