[email protected]Office hours: Mon – Fri 9:00AM – 5:00PMLinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedSeptember 8, 2023

How to Install R on CentOS 7

How To Install R On CentOS 7

This tutorial will teach you how to install R on CentOS 7 and how to install R packages from the official Comprehensive R Archive Network (CRAN) .

 

Installing R on Centos

At the time of writing the latest stable version of R is version 3.5.

To install R on CentOS 7, follow these steps:

  1. R packages are available in the EPEL repositories. If you don’t have EPEL repository installed on your machine you can do it by typing:

    sudo yum install epel-release

    You will be prompted to accept the repository GPG key, type y and hit Enter.

  2. Once the repository is added, install R by typing:

    sudo yum install R

    R is a meta package that contains all the necessary R components.

  3. Verify the installation by typing the following command which will print the R version:

    R --version
    R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
    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
    https://www.gnu.org/licenses/.

 

Installing R Packages from CRAN

One of the main reasons why R is so popular is the wide array of packages available through the Comprehensive R Archive Network (CRAN).

For demonstration purposes, we’ll install a package named stringr , which provides fast and correct implementations of common string manipulations.

When started as root the packages will be installed globally and available for all system users. If you start R without sudo, a personal library will be set up for your user.

Start by opening the R console as a root:

sudo -i R
R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
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 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.

>

Install the stringr package by running the following command:

install.packages("stringr")

You will be asked to select a CRAN mirror:

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

Select the mirror that is closest to your location.

The installation will take some time and once completed, load the library by typing:

library(stringr)

Next, create a simple character vector named tutorial:

tutorial <- c("How", "to", "Install", "R", "on", "CentOS", "7")

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

str_length(tutorial)
[1] 3 2 7 1 2 6 1

 

Conclusion

You have successfully installed R your CentOS machine and learned how to install R packages.

Keep reading
How to Implement Network Segmentation and Resource Isolation in Linux.
February 6, 2024

How to Implement Network Segmentation and Resource Isolation in Linux.

How to Implement Network Segmentation and Resource Isolation in Linux. Securing and managing networks in a Linux environment involves advanced practices like network segmentation and resource isolation. This guide explores these concepts, providing detailed instructions and examples for…

Read article
How to open or close ports in Linux.
February 6, 2024

How to open or close ports in Linux.

How to open or close ports in Linux. Effectively managing ports on your Linux system is crucial for both security and service accessibility. This comprehensive guide will provide a detailed walkthrough on opening and closing ports using the robust tools iptables and ufw. Understanding these…

Read article
How to use ypdomainname command.
January 23, 2024

How to use ypdomainname command.

How to use ypdomainname command. In the realm of Linux networking, the ypdomainname command plays a crucial role in the context of the Network Information Service (NIS). NIS, formerly known as Yellow Pages, is a distributed database service that facilitates the sharing of network configuration and…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, colocation, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Office hours: Mon – Fri 9:00AM – 5:00PM