R is an open source programming language and free environment, mainly used for statistical analysis and drawing. It is supported by the R Foundation and is mainly used for statistical analysis. It is mainly used by data statistics and analysts to develop statistical software and for data analysis.
This article mainly describes how to install R on CentOS 8.
Before proceeding with this guide, please make sure you meet the following prerequisites:
The R package is not included in the core software source of CentOS 8. We need to install R from the EPEL software source.
To install R on CentOS 8, follow the steps below:
sudo dnf install epel-release
sudo dnf config-manager --set-enabled PowerTools
sudo yum install R
R is a meta-package that contains all the necessary R components.
R --version
At this time, the most stable version of R is 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
https://www.gnu.org/licenses/.
sudo yum install make gcc gcc-c++ libcurl-devel libxml2-devel openssl-devel texlive-*
that's it! You have successfully installed R on your CentOS system, and you can start using it.
One of the main reasons for R's popularity is that many software packages are provided through the Comprehensive R Archive Network (CRAN).
If R is installed with Root or sudo, the package will be installed globally and available to all system users. Want to set up a personal library for your user, install the binary package as a normal user.
As an example, we will install a package called stringr
, which provides a quick implementation of usual string operations.
Open the R terminal as root:
sudo -i R
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 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 interfaceto help.
Type 'q()' to quit R.>
Enter the following command in the R terminal and execute it.
Install the stringr
package:
install.packages("stringr")
You will be asked to choose a CRAN mirror:
Installing package into ‘/usr/lib64/R/library’(as ‘lib’ is unspecified)--- Please select a CRAN mirror for use inthis session ---
Secure CRAN mirrors
Choose a mirror image closest to your location.
The installation will take some time. Once completed, enter the following command to load the library:
library(stringr)
Next, create a simple string with the command'tutorial':
tutorial <-c("How","to","Install","R","on","CentOS","8")
Running the following function will print out the length of each string:
str_length(tutorial)
[1]3271261
You can find more R packages in CRAN package page, and install them via install.packages()
.
We have shown you how to install R on CentOS 8 and how to install R packages.
Recommended Posts