How to Install and Compile R on Ubuntu 20.04

how to install R and compile on ubuntu 20.04

R is a most widely used open-source programming language among statisticians and data miners to develop a statistical software, data analysis and more. It’s a free software environment for statistical computing, graphical and visual presentation by the R foundation.

In this tutorial we cover how to install and compile R on Ubuntu 20.04. Let’s start the tutorial.

Install R:

By default, R packages are available in the Ubuntu repositories, but we can’t find always the latest release of R packages. Find trusted external repository and install R on Ubuntu, we can install it by CRAN repository. Let’s begin the R installation.

To install the R on ubuntu 20.04 first we need to add the GPG key

sudo apt-key adv --keyserver --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
Executing: /tmp/apt-key-gpghome.JC9K3gjUVy/ --keyserver keyserver.ubuntu                                                                                                             .com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
gpg: key 51716619E084DAB9: public key "Michael Rutter " impo                                                                                                             rted
gpg: Total number processed: 1
gpg:               imported: 1

After adding trusted GPG key to your Ubuntu 20.04 server, then add the repository from R Ubuntu packages. Ubuntu 20.04 is known as Focal Fossa.

sudo add-apt-repository 'deb focal-cran40/'

To Update the repository run the commands below:

sudo apt update

To install R on Ubuntu 20.04 run the commands below:

sudo apt install r-base

After installation of R check the version.

R --version
R version 4.0.1 (2020-06-06) -- "See Things Now"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see

Hooray we have successfully installed R on Ubuntu 20.04 server. Let start compiling R.

Compile R:

CRAN have more R packages you can find install it by install.packages(). For this tutorial we can install string package.

To open R run the following command:


To install and load the stringr package from CRAN execute the command below:


Create a simple task:

technologytu <- c("Technology", "Tutorials", "is", "the", "Best", "Blog", "for", "Learning")
[1] 10  9  2  3  4  4  3  8


We successfully installed R on ubuntu 20.04. We learned how to install and Compile R on ubuntu 20.04.

Leave a Reply

Post your comments here

You May Also Like