Install R Programming Language on Linux Mint 20 LTS

R is an open-source programming language and free software environment for statistical computing and graphical representation created and supported by the R Core Team and the R Foundation. R’s popularity is widely used among statisticians and data miners for software developers’ statistical and data analysis.

In the following tutorial, you will learn how to install R using the CRAN repository and install packages from R’s CRAN repository or PPA cran2deb4ubuntu on Linux Mint 20.

Update Linux Mint System

Update your Linux Mint operating system to make sure all existing packages are up to date:

sudo apt update && sudo apt upgrade -y

Install Depedencies

To complete the installation, you may need to install the following dependencies.

sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common -y

Import R GPG Key & CRAN Repository

By default, R is present in Linux Mint’s repositories. However, it is very outdated, and it is highly recommended to install R from the CRAN repository.

First, import the GPG required to verify the R package’s authenticity.

sudo apt-key adv --keyserver --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9

Example if the import was successful:

Install R Programming Language on Linux Mint 20

Next, import the CRAN repository.

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

Once imported, refresh your APT repository list.

sudo apt update

Install R Programming Language

With the dependencies and the newly added CRAN repository installed, you can install the R language by executing the following command in your terminal.

sudo apt install r-base r-base-dev

Example output:

Install R Programming Language on Linux Mint 20

Once the installation has finished, verify if it was successful by checking the build version.

R --version

Example output:

Install R Programming Language on Linux Mint 20

Install R Packages from CRAN

Now that R is installed on your system, you can launch the R terminal instance.

In your terminal, use the following command.

sudo -i R

Example out R terminal:

Install R Programming Language on Linux Mint 20

R has quite an extensive range of packages that you can install. For the tutorial, the “txtplot” package returns ASCII graphs with “line plot, scatter plot, bar charts, and density plot.” This is installed by using the install.packages(”) command in R’s terminal shell.


Example output:

Install R Programming Language on Linux Mint 20

With “textplot” now installed, you can run a test by activating the package in the R shell terminal.


Next, an example is shown using the example data supplied by R’s “datasets” package containing the speed of cars and the distance required to stop based on data from the 1920s.

txtplot(cars[,1], cars[,2], xlab = 'speed', ylab = 'distance')

From this input command, you will then receive a plot graph.


Install R Programming Language on Linux Mint 20

Additionally, you can use the following command to get help on the packages installed.

help(package name)

Replace “package name” with the package installed. In the tutorial’s case, this was “txtplot”.



To remove a package, or “txtplot” use the following remove command in the R shell terminal.


To exit the R shell terminal interface, use the “q()” command.


You will see the following prompt:

Save workspace image? [y/n/c]: 

Select your option to exit by typing y, n, or and pressing the “ENTER KEY”.

Install R Packages from cran2deb4ubuntu

Optionally, you can install the following PPA cran2deb4ubuntu, a PPA for R packages from CRAN’s Task Views built against R 4.0 (and subsequent releases). Note that this PPA only works for LTS releases such as 18.04, 20.04, and the upcoming 22.04 LTS but is built with the latest R version.

First, install the PPA using the following command.

sudo add-apt-repository -y

Once installed, update the APT repository list.

sudo apt update

Note, you may see updated packages, upgrade as appropriate.

sudo apt upgrade

Instead of compiling the R packages, this may suit the developer, and you can install them as packages from the PPA. However, you will rely on the PPA to maintain and keep secure.

Overall, the PPA by the “cran2deb4ubuntu Build Team” team is very well known and can be trusted.

Comments and Conclusion

In the tutorial, you have learned how to install R on Linux Mint 20 by using the CRAN repository, which you can draw upon packages and updates frequently.

One of the best parts about R programming is that it is more of a community-run software, which means that anyone can provide code enhancements and new packages. The consistency in the R community environment is a testament to this approach to developing specific software by sharing and encouraging inputs. This tool is also compatible across platforms, and thereby it runs on many operating systems as well as hardware.

Additionally, you can find more R packages at Available CRAN Packages By Name.


Like to get automatic updates? Follow us on one of our social media accounts!