R is a free, open source programming language that specializes in graphical representation, reporting, and statistical computing. It compiles and runs on various operating systems such as UNIX, MacOS, and Windows. R is supported by the R Foundation for statistical analysis. It is commonly used by data miners and statisticians to analyze data and develop statistical software.
In this article, you will learn how to install R on CentOS 8 using the command line.
To install R on CentOS 8, you must make sure that your system memory has at least 1 GB.
To start installing steps R ’on your system using the terminal, you need to follow these steps:
Logging in as root means that you must have “sudo” permissions to install packages on your system.
- Open the terminal application using the keyboard shortcut Ctrl + Alt + t. Or you can also open the terminal by clicking on “Actions”.
Install R on CentOS 8
R packages are not included in the main CentOS 8 repositories. You need to install R through the EPEL repository. To enable epel repository and configuration management tools, you will use the following command on the terminal:
$ sudo dnf install epel-release
$ sudo dnf config-manager --set-enabled PowerTools
During installation, a user prompt will be displayed on the screen. You press “y” and then “Enter” to continue installing epel-release.
After a while, the terminal will display a full status indicating that the installation is complete.
You will now turn on the necessary power tools in your system for installation.
Install R on CentOS 8
After successfully enabling repositories and power tools, it’s time to install R on your system. Now you install R using the yum package manager on CentOS 8. To do this, run the following command in a terminal window:
$ sudo yum install R
Here, R is a metapackage. All necessary R components are included in the aforementioned meta package.
During the installation of R on CentOS 8, a confirmation message will be displayed on your system, asking you to confirm the installation of the remaining packages. You press “y” and then “Enter” to continue installing additional R packages on your system.
Again, a confirmation message appears on the terminal, which asks you to confirm the import of the GPG key for installing R. Type ‘y’ and then “Enter” to continue the installation process.
After all the R components are successfully installed on the terminal, the “Complete” status will appear, which indicates that R has been successfully installed on your system.
Check R setting
You can verify the installation of R on your system using the following command on the terminal:
The screenshot above shows that R was successfully installed on your system. At the time of this writing, version 3.6.3 is the latest stable version of R.
Install tools and libraries for building R
You need to install the auxiliary libraries and tools necessary for the R packages on your system. Use the following command to install the necessary tools and libraries:
During installation, you will be asked to confirm the installation. You press “y” and then press “Enter” to continue installing the necessary tools and libraries.
When all the libraries and tools are installed on your system, the terminal will display the “Complete” status, which means that the installation is completed.
Open R console as root
Now that you start with R, open the R console on the terminal as root. Use the following command to open R:
If you run the R binary as root, the packages will be installed globally and are available to all users of the system. You can configure your personal library to use, call the binary R as a regular user.
Now all of the commands below will be executed in the R console.
R has a huge array of packages available that can be installed using the Integrated Archiving Network R (CRAN).
For example, you want to install the R package, known as “stringr”, which is usually used to correctly and quickly implement string manipulations.
Install stringr in console R via terminal. Enter the following command to install the stringr package:
After executing the above command, a list of CRAN mirrors will appear on the terminal, which will ask you to select a CRAN mirror for use.
Now you will select the nearest mirror to your location. For example, Mexico City is closest to your location, then enter its number in the “39” field.
Installation will take some time to complete. After installation is complete, you will download the library using the following command in the terminal window:
Now you will create a vector called article using the following syntax:
> article <- c(“Article”, “About”, "How", "to", "Install", "R", "on", "CentOS", "8")
Use the following function to print the length of each line:
Now you can close the R console by typing the following command in the terminal:
In this article, you learned how to install R on CentOS 8 using a terminal. You also learned how you can install various R packages on your system. I hope you enjoyed this article and it came in handy. Please leave your feedback through the comments.
How to install and use the R programming language on CentOS 8