R is a free and open-source programming language that specializes in graphical representation, reporting, and statistical computing. It compiles and executes on a variety of operating systems like UNIX, MacOS, and Windows. R is supported by R Foundation for statistical analysis. It is commonly used by data miners and statisticians for performing data analysis and developing statistical software.
In this article, you will learn how you can install R on CentOS 8 using the command line.
To install R on CentOS 8, you must ensure that your system RAM has at least 1G space.
You need to perform the following steps to start the installation of ‘R’ on your system using the terminal:
Log in as the root user means you must have ‘sudo’ command privileges to install packages on your system.
Open the terminal application through the shortcut method ‘Ctrl + Alt + t’. Or you can also open the terminal by clicking on the ‘Activities’.
Installation of R on CentOS 8
The R packages are not incorporated in the core repositories of CentOS 8. You need to install R through the EPEL repository. To enable epel repository and configuration management power tools, you will use the following command on the terminal:
$ sudo dnf install epel-release
$ sudo dnf config-manager --set-enabled PowerTools
During the installation, a user prompt will display on the screen. You will press ‘y’ and then ‘Enter’ to further proceed with the installation of epel- release.
In a while, a complete status will appear on the terminal that indicates the installation has been completed.
Now, you will enable the necessary power tools on your system for installation.
Install R on CentOS 8
After successfully enabling the repositories and power tools, it’s time to install R on your system. Now, you will install R using the ‘yum’ package manager on your CentOS 8. For that purpose, execute the following command on the terminal window:
$ sudo yum install R
Here, R indicates a meta-package. All necessary R components are included in above-mentioned meta- package.
During the installation of R on CentOS 8, a user confirmation prompt would display on your system that would ask to confirm the installation of the remaining packages. You will press ‘y’ and then ‘Enter’ key to continue the installation of more R packages on your system.
Again confirmation prompt will display on the terminal that will ask about the confirmation of import GPG key for the installation of R. Type ‘y’ and then ‘Enter’ to continue the installation process.
After the successful installation of all R components, A ‘Complete’ status would appear on the terminal that will show R has been successfully installed on your system.
Verify the installation of R
You can verify the installation of R on your system by using the following command on the terminal:
You can see in the above display screenshot that R has been successfully installed on your system. At the time of writing this article, version 3.6.3 is the latest stable version of R available.
Install R build tools and libraries
You need to install the supportive libraries and tools on your system that are necessary for R packages. Use the following command to install the necessary tools and libraries:
During the installation, it will ask you about the confirmation for installation. You will press ‘y’ and then hit ‘Enter’ to further continue the installation of necessary tools and libraries.
When all libraries and tools will be installed on your system, A ‘Complete’ status will display on the terminal that means installation has been completed.
Open R console as root
Now, you will start with R, open the R console on the terminal as root. Use the following command to open R:
If you will launch the R binary as root, then the packages will install globally and available for all users of the system. You can set up a personal library for use, invoke the R binary as a regular user.
Now all below-mentioned commands will run within the R console.
In the R, a huge array of packages are available that can be installed using the Comprehensive R Archive Network (CRAN).
For example, you want to install a package of R known as ‘stringr’ which is commonly used for correct and fast implementations of string manipulations.
Install stringr within the R console through the terminal. Type the following command to install stringr package:
After executing the above-given command, a list of CRAN mirrors will appear on the terminal that will be asked to select a CRAN mirror for use.
Now, you will select the closest mirror to your location. For example, Mexico City is closest to your location then enter its number in the selection ‘39’.
The installation will take some time for completion. Once the installation is completed now, you will load the library by using the following command on the terminal window:
Now, you will create a vector named with 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 string:
Now you can close the R console by typing the following command on the terminal:
In this article, you have learned how to install R on CentOS 8 using the terminal. You have also learned how you can install various R packages on your system. I hope you have enjoyed this article and useful for you. Please give us your feedback via comments.