• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install R on CentOS 7

Written by Admin, Updated On July 28, 2019
centos, r
How to Install R on CentOS 7

R is a open source programming language and free software environment for statistical computing with graphical interface. R language specially used for statistical computing and data mining for developing statistical software and performing data analysis. In this tutorial described how to install R on CentOS 7 system.

Prerequisites#

Before you start installation on CentOS, ensure that you are logged in with non-root user account with administrator privileges.

Installing R on CentOS#

R packages are available in the EPEL repositories. If EPEL repository not installed on your machine you then add it using below command:

sudo yum install epel-release

It will prompt to accept the repository GPG key, type y and hit Enter.

Once the repository added issue below command to install R:

sudo yum install R

You can verify the installation by running the following command which will print the R version:

R --version
Output
R version 3.5.3 (2019-04-03) -- "Joy in Playing" 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 http://www.gnu.org/licenses/.

Install R Packages from CRAN#

R is so popular because of wide availability of packages through the Comprehensive R Archive Network (CRAN).

We are going to install a stringr package for an example, which provides fast, correct implementations of common string manipulations.

Start by opening the R console as root:

sudo -i R

It will show as below:

R version 3.5.3 (2019-04-03) -- "Joy in Playing"
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.

>

To install stringr package just type:

install.packages("stringr")

It will show output as below:

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.

Installation will take some time and after completion load library using:

library(stringr)

Let’s create a simple vector named demo:

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

Now run the below command to print the length of a string:

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

If you want to install more packages you can find it at CRAN Packages.

Conclusion#

You have successfully learned how to install R on Debian 9 system. If you have any problem or suggestion please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Unzip Files in Linux
Next Article   How to Install Anaconda on CentOS 7

Related Posts

  • How to Install R on Ubuntu 22.04

    How to Install R on Ubuntu 22.04

    February 6, 2023
  • How to Install Php 8 on CentOS 8

    How to Install PHP 8 on CentOS 8

    January 27, 2021
  • How to Install Python 3.9 on CentOS 8

    How to Install Python 3.9 on CentOS 8

    December 31, 2020

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook