How to install and use the R programming language on CentOS 8

s2 0

R is a free and open source programming language that specializes in graphing, reporting, and statistical calculations. It compiles and runs on a wide variety of operating systems such as UNIX, macOS, and Windows. R is supported by the R Foundation for statistical analysis. It is widely used by data miners and statisticians to perform data analysis and develop statistical software.

This article shows you how to install R on CentOS 8 from the command line.


To install R on CentOS 8, you need to make sure that your system RAM has at least 1GB of space.

You need to follow the steps below to start the installation of ‘R’ on your system from the terminal:

If you log in as the root user, you must have sudo command permission to install packages on your system.

  1. Open the terminal application using the shortcut method ‘Ctrl + Alt + t’. Or you can open the terminal by clicking on “Activities”.

Installation of R on CentOS 8

The R packages are not in the CentOS 8 core repositories. You need to install R from the EPEL repository. To enable the epel repository and configuration management power tools, use the following command on the terminal:

$ sudo dnf install epel-release
$ sudo dnf config-manager --set-enabled PowerTools

A user prompt will appear on the screen during the installation. You will press ‘y’ and then ‘Enter’ to proceed with the installation of epel-release.

Confirm installation

installation completed
After a while, the terminal will show a full status indicating that the installation is complete.

Now activate the required power tools on your system for installation.

Activate PowerTools

Install R on CentOS 8

Now that you’ve successfully activated the repositories and power tools, it’s time to install R on your system. Now install R with the package manager ‘yum’ on your CentOS 8. To do this, run the following command in the terminal window:advertising

$ sudo yum install R

Install the R language package

Here R denotes a metapackage. All the necessary R components are contained in the metapackage mentioned above.

Install dependencies

During the installation of R on CentOS 8, a user confirmation prompt will appear on your system asking you to confirm the installation of the remaining packages. You press ‘y’ and then ‘Enter’ to continue installing more R packages on your system.

Confirm installation

A confirmation prompt is displayed again on the terminal asking for confirmation of the import of the GPG key for the installation of R. Enter ‘y’ then ‘Enter’ to continue the installation process.

Accept the Epel repository key

After the successful installation of all R components, the status ‘Complete’ appears on the terminal, which indicates that R has been successfully installed on your system.

Package installation completed

Check the installation of R

You can verify the installation of R on your system by using the following command on the terminal:

Check which version of R is installed

In the screenshot above, you can see that R has been successfully installed on your system. At the time of this writing, version 3.6.3 is the latest stable version of R that is available.

Install R build tools and libraries

You must install the supporting libraries and tools on your system that are required for R packages. Use the following command to install the required tools and libraries:

Install build tools

During the installation you will be asked to confirm the installation. You press ‘y’ then press ‘Enter’ to continue installing the required tools and libraries.

Confirm installation

When all the libraries and tools are installed on your system, the terminal will show the status ‘Complete’, which means the installation is complete.

installation completed

Open the R console as root

Now starting with R, open the R console on the terminal as root. Use the following command to open R:

R programming console

If you start the R binary as root, the packages are installed globally and are available to all users of the system. You can set up a personal library to use and access the R binary as a normal user.

Now all of the below mentioned commands will be executed in the R console.

Install stringer

There is a huge selection of packages available in R that can be installed over the Comprehensive R Archive Network (CRAN).

For example, you might want to install a package from R known as ‘stringr’, which is widely used for the correct and quick implementation of string manipulations.

Install stringr in the R console through the terminal. Enter the following command to install the Stringr package:

> install.packages("stringr")

After executing the above command, a list of CRAN mirrors appears on the terminal, prompting you to select a CRAN mirror to use.

Install the Stringr library

Now choose the mirror that is closest to your location. For example Mexico City is closest to your location, then enter its number in the selection ’39’.

Select download mirror

The installation will take some time. Once the installation is now complete, load the library using the following command in the terminal window:

> library(stringr)

Stringer library in R.  load

Now create a vector named article using the following syntax:

> article <- c(“Article”, “About”, "How", "to", "Install", "R", "on", "CentOS", "8")

Use stringr library

Use the following function to get the length of each string:

> str_length(article)

Print string lengths

Now you can close the R console by typing the following command on the terminal:

> q()

Close the R prompt


In this article you learned how to install R on CentOS 8 using the terminal. You also learned how to install various R packages on your system. Hope you enjoyed and found this article useful. Please give us your feedback via comments.

How to install and use the R programming language on CentOS 8