How to install and configure R on CentOS 8

R is a fast-growing open source programming language that specializes in statistical computing and graphical representation.

This programming language is supported by the R Foundation for Statistical Computing and is mainly used by statisticians and data miners to develop statistical software and perform data analysis.

This tutorial will teach you how to install R on CentOS 8.


Make sure you meet the following prerequisites before continuing with this tutorial:

  • Your system contains at least 1 GB of RAM. If not, you can create a swap file.
  • You are logged in as a user with sudo privileges.

Install R on Centos 8

R package is not included in the CentOS 8 base repository, we will install R from the EPEL repository:

To install R on CentOS 8, follow these steps:

  1. Enable EPEL and PowerTools repositories:
    sudo dnf install epel-release
    sudo dnf config-manager --set-enabled PowerTools
  2. Install R by typing:
    sudo yum install R

    R is a descriptive package that contains all of the R components.

  3. Verify the installation by printing the R version:
    R --version

    At the time of writing, the most recent stable R release is the 3.6.2:

    R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
    Copyright (C) 2019 The R Foundation for Statistical Computing
    Platform: x86_64-redhat-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
  4. Install the libraries and tools used by the R package:
    sudo yum install make gcc gcc-c++ libcurl-devel libxml2-devel openssl-devel texlive-*

At this point, you have successfully installed R on your CentOS system and you can start using it.

See also  How To Install PHP 8.0 on Amazon Linux 2

Install Package R from CRAN

One of the main reasons for R’s popularity is the great variety of packages available through the R’s comprehensive archive network (CRAN).

For demo purposes, we will be installing a package named stringr, Which provides fast and correct implementation of general chain processing.

When started as root, the packages will be installed globally and available to all system users. If you start R without sudo, it will create a private library for users.

Start by opening R console as root:

sudo -i R
R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
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 certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

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.


All the following commands are executed in the R console.

Install the package stringr By running the following command:


You will be prompted to specify the CRAN mirror link:

Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Secure CRAN mirrors 

Choose the mirror closest to your location.

It will take some time to install and once completed, download the library by typing:


Next, create a simple letter vector called tutorial:

tutorial <- c("Cara", "Install", "R", "di", "CentOS", "8")

Run the following function that will print the length of each string:

[1] 4 7 1 2 6 1

You can find more R packages in CRAN package by name supplied and installed with install.packages().


You have successfully installed your CentOS R device and learned how to install R package.

See also  Redirecting non-www to www with Nginx on Ubuntu


Source link

Originally posted 2020-11-17 14:44:16.

About wahyuway

Check Also

How To Deploy Droplet on DigitalOcean With Terraform

Hello good people. In today’s blog post we will be showing you how to create …

Leave a Reply