Home » Operating System » Linux » How To Install R on Ubuntu 18.04

Address

Jl. Meranti Wing 22 Level 4
Kampus IPB Darmaga
Bogor 16680, Jawa Barat, Indonesia
Tlp./Fax +62 (251) 8624535

Hours
Monday—Friday: 08:00–16:00

How To Install R on Ubuntu 18.04

Introduction

R is an open-source programming language that specializes in statistical computing and graphics. In this tutorial, we will install R on an Ubuntu 18.04 server.

For a more detailed version of this tutorial, with better explanations of each step, please refer to How To Install R on Ubuntu 18.04.

Step 1 — Add GPG Key

The Ubuntu archives on CRAN are signed with the key of “Michael Rutter ” with key ID 0x51716619e084dab9. To add the key to your system with one command use (thanks to Brett Presnell for the tip):

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

An alternate method can be used by retrieving the key with

gpg --keyserver keyserver.ubuntu.com --recv-key E298A3A825C0D65DFD57CBB651716619E084DAB9

and then feed it to apt-key with

gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | sudo apt-key add -

Some people have reported difficulties using this approach. The issue is usually related to a firewall blocking port 11371. If the first gpg command fails, you may want to try (thanks to Mischan Toosarani for the tip):

gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9

and then feed it to apt-key with

gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | sudo apt-key add -

Another alternative approach is to search for the key at http://keyserver.ubuntu.com:11371/ and copy the key to a plain text file, say key.txt. Then, feed the key to apt-key with

sudo apt-key add key.txt

Step 2 — Add the R Repository

To obtain the latest R 4.0 packages, add an entry like

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

or

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

or

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

Step 3 — Update Package Lists

  • sudo apt update

Step 4 — Install R

  • sudo apt install r-base r-base-dev

If prompted to confirm installation, press y to continue.

Step 5 — Test Install

Start R’s interactive shell as root.

  • sudo -i R

You should receive output similar to the following:

Output

R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

>

This confirms that we’ve successfully installed R and entered its interactive shell.

Source:

  • https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-18-04-quickstart

Leave a comment

November 2018
M T W T F S S
 1234
567891011
12131415161718
19202122232425
2627282930  

Categories