Install R and RStudio on RHEL9 or CentOS9

Install R and RStudio on RHEL9

In this article, we will guide you on how to install R and RStudio on RHEL9 or CentOS9. As well as, provide you with best practices for maintaining a secure instance of R and RStudio.

Table of Contents

Introduction

R is a popular programming language and software environment used for statistical computing and graphics. It was created by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand, in the mid-1990s. R is an open-source project that has gained popularity among statisticians, data analysts, and data scientists worldwide due to its flexibility, functionality, and ease of use. In this article, we will guide you on how to install R and Rstudio on RHEL9 or CentOS9.

Step 1: Update System

Before installing R and Rstudio, it is always good to update the system (in this case RHEL9 or CentOS9) using the following command:

				
					$ sudo dnf update
				
			

Step 2: Enable EPEL

R and Rstudio are not available in the default repository of RHEL9 or CentOS9. We need to enable the EPEL (Extra Packages for Enterprise Linux) repository to install them. Run the following command to enable the EPEL repository:

On RHEL9:

				
					$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %rhel).noarch.rpm
				
			

Also, to install the full suite of R packages (include R-devel, R-java, R-devel, etc…) on your RHEL9 machine, you will need to enable the CodeReady Builder repository as well. Run the following command to enable it:

				
					$ sudo /usr/bin/crb enable
Enabling CRB repo
Repository 'codeready-builder-for-rhel-9-x86_64-rpms' is enabled for this system.
CRB repo is enabled and named: codeready-builder-for-rhel-9-x86_64-rpms

				
			

On CentOS9:

				
					$ sudo dnf install epel-release
				
			

To enable the CodeReady Builder repository on CentOS9 issue the same command:

				
					$ sudo /usr/bin/crb enable
Enabling CRB repo
CRB repo is enabled and named: crb
				
			

Step 3: Install R

Now that the EPEL and CodeReady Builder repositories are enabled, we can install R using the following command:

				
					$ sudo dnf install R
Last metadata expiration check: 0:13:46 ago on Thu 23 Mar 2023 12:23:55 AM EDT.
Dependencies resolved.
===================================================================================================================================================
 Package                                           Architecture        Version                                        Repository              Size
===================================================================================================================================================
Installing:
 R                                                 x86_64              4.2.2-1.el9                                    epel                   9.5 k
Installing dependencies:
 R-core                                            x86_64              4.2.2-1.el9                                    epel                    60 M
 R-core-devel                                      x86_64              4.2.2-1.el9                                    epel                    84 k
 R-devel                                           x86_64              4.2.2-1.el9                                    epel                   9.0 k
 R-java                                            x86_64              4.2.2-1.el9                                    epel                    10 k
 R-java-devel                                      x86_64              4.2.2-1.el9                                    epel                   9.6 k
 R-rpm-macros                                      noarch              1.2.1-4.el9                                    epel                    11 k
 adobe-mappings-cmap                               noarch              20171205-12.el9                                appstream              1.9 M
 adobe-mappings-cmap-deprecated                    noarch              20171205-12.el9                                appstream              107 k
 adobe-mappings-pdf                                noarch              20180407-10.el9                                appstream              646 k
 annobin                                           x86_64              11.13-1.el9                                    appstream              975 k
 brotli                                            x86_64              1.0.9-6.el9                                    appstream              313 k
 brotli-devel                                      x86_64              1.0.9-6.el9                                    appstream               32 k
 bzip2-devel                                       x86_64              1.0.8-8.el9                                    appstream              215 k
 cmake-filesystem                                  x86_64              3.20.2-8.el9                                   appstream               19 k
 color-filesystem                                  noarch              1-28.el9                                       appstream              8.8 k
 colord                                            x86_64              1.4.5-4.el9                                    appstream              555 k
 cups-client                                       x86_64              1:2.3.3op2-16.el9                              appstream               74 k
 cups-filesystem                                   noarch              1:2.3.3op2-16.el9                              appstream               14 k
 cups-filters                                      x86_64              1.28.7-11.el9                                  appstream              784 k
 cups-filters-libs                                 x86_64              1.28.7-11.el9                                  appstream              134 k
 dwz                                               x86_64              0.14-3.el9                                     appstream              128 k
 efi-srpm-macros                                   noarch              4-9.el9                                        appstream               23 k
 flexiblas                                         x86_64              3.0.4-8.el9                                    appstream               33 k
 flexiblas-devel                                   x86_64              3.0.4-8.el9                                    crb                    108 k
 flexiblas-netlib                                  x86_64              3.0.4-8.el9                                    appstream              3.0 M
 flexiblas-netlib64                                x86_64              3.0.4-8.el9                                    crb                    2.9 M
... output omitted ...
				
			

Step 4: Install RStudio

To install the RStudio server, which allows you to deploy an Integrated Development Environment (IDE) that is accessible from your web browser, run the following command:

				
					$ sudo dnf install https://download2.rstudio.org/server/rhel9/x86_64/rstudio-server-rhel-2023.03.0-386-x86_64.rpm 

Last metadata expiration check: 0:43:39 ago on Thu 23 Mar 2023 12:23:55 AM EDT.
rstudio-server-rhel-2023.03.0-386-x86_64.rpm                                                                        24 MB/s |  73 MB     00:02    
Dependencies resolved.
===================================================================================================================================================
 Package                              Architecture                 Version                                Repository                          Size
===================================================================================================================================================
Installing:
 rstudio-server                       x86_64                       2023.03.0+386-1                        @commandline                        73 M
Installing dependencies:
 libpq                                x86_64                       13.5-1.el9                             appstream                          207 k
 sqlite                               x86_64                       3.34.1-6.el9                           appstream                          748 k

Transaction Summary
===================================================================================================================================================
Install  3 Packages

Total size: 74 M
Total download size: 955 k
Installed size: 360 M
Is this ok [y/N]: y

				
			

Note: This will download and install the rstudio-server-rhel-2023.03.0-386-x86_64.rpm . For the latest version, visit the official website here.

Step 5: Verify Installs

Once the installation is complete, you can verify it by running the following command:

				
					$ R --version; rstudio-server version

R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
Copyright (C) 2022 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/.

2023.03.0+386 (Cherry Blossom) for RHEL 9

				
			

Ensure that TCP port 8787 is open to enable Rstudio access from your web browser.

				
					$ sudo firewall-cmd --permanent --add-port=8787/tcp
success

$ sudo firewall-cmd --reload
success

				
			

Enter http://your-rstudio-server-hostname:8787 or http://localhost:8787 to pull up the login page.

Install R and RStudio on RHEL9

Photo by admingeek from Infotechys

Then, enter your username and password (your normal Linux user credentials) to sign.

Install R and RStudio on RHEL9

Photo by admingeek from Infotechys

That it! We’ve successfully installed R and Rstudio on RHEL9 or CentOS9. You can now install other packages/libraries and explore other R and Rstudio features!

Install R and RStudio on RHEL9 or CentOS9: Features

R and Rstudio come with various features that make them useful for data analysis, visualization, and machine learning. Some of the key features are:

  • Data visualization: R provides a wide range of graphical tools and libraries that can be used to visualize data in various formats, including charts, histograms, scatter plots, and more.

  • Statistical analysis: R provides a powerful set of functions for statistical analysis, such as regression analysis, hypothesis testing, and more.

  • Machine learning: R provides numerous packages and tools for machine learning tasks such as clustering, classification, and regression.

  • Data manipulation: R provides a set of functions for data manipulation tasks such as filtering, sorting, merging, and more.

  • Integrated development environment (IDE): Rstudio provides an intuitive IDE that makes it easy to write, debug, and test R code.

Best Practices

When installing R and Rstudio on RHEL9 or CentOS9, it is essential to follow some best practices to ensure that the installation is successful and that the system is secure. Here are some best practices that you can follow:

  • Always update the system before installing any software or package to ensure that you have the latest security patches and updates.

  • Use the official repository to install R and Rstudio instead of third-party sources to ensure that you get the latest stable version.

  • Enable the EPEL repository as it contains the necessary dependencies for R, Rstudio, and other packages that you might need in the future.

  • Verify the installation to ensure that R and Rstudio are installed correctly, and there are no errors or issues.

  • Keep R, Rstudio, and their dependencies up to date by regularly updating the system and the packages installed.

  • Use a virtual environment to isolate R, Rstudio, and their dependencies from other applications and packages that might cause conflicts or issues.

  • Always use secure passwords and user authentication to protect your system and data from unauthorized access.

Conclusion

R and Rstudio are powerful tools for data analysis, visualization, and machine learning. They come with various features that make them useful for data-related tasks, and their popularity has grown exponentially in recent years. In this article, we have provided a step-by-step guide on how to install R and Rstudio on RHEL9 or CentOS9. We have also highlighted some of the key features of R and Rstudio and provided some best practices that you can follow to ensure a successful installation.

By following these instructions, you can set up R and Rstudio on your system and start analyzing your data. Was this article helpful to you? If so, let us know in the comments section below and share this page!

Related Posts

Install EPEL
Commands
Install EPEL on Linux

In this article, we will guide you through the process of installing EPEL on various versions of RHEL and CentOS. Table of Contents Introduction The

Read More »

Leave a Reply

Your email address will not be published. Required fields are marked *