R is an open-source programming language and free software environment for statistical computing and graphical representation created and supported by the R Core Team and the R Foundation. R’s popularity is widely used amongst statisticians and data miners for statistical and data analysis software developers. The R language, otherwise called GNU S, was created in 1992 by Robert Gentleman and Ross Ihaka at the University of Auckland, New Zealand, with support from the Statistical Society of New Zealand. R has become the de facto standard among statisticians for statistical computing, data analysis, and machine learning.
R is so popular because it’s a versatile tool that can be used for everything from simple data analysis to complex statistical modeling. For example, R can be used to clean and prepare data for analysis, Perform statistical analyses, Create publication-quality plots, and Present results in an interactive web application. As a result, it’s no wonder that R has become one of the most popular programming languages in the world.
In the following tutorial, you will learn how to install R on Fedora 36 Linux using the command line terminal, along with some basic commands and examples of what can be achieved with R Programming.
Table of Contents
First, update your system to ensure all existing packages are up to date.
sudo dnf upgrade --refresh -y
Install R Programming Language
R comes in Fedora’s default repository, so it is straightforward to install. The most recommended option is to install the default package that includes everything.
Execute the following command in your terminal to begin the installation.
sudo dnf install R
Note, if the installation command does not work, make sure the R is in CAPITALS!!!!!!!!!!!!!!!
Once the installation has finished, verify if it was successful by checking the build version.
Alternative Install Options
As mentioned, the default option is to install R with all its dependencies. However, some may want a unique installation, and the following command will also install R in various optional ways.
Install the minimal R components:
sudo dnf install R-core -y
Install the core files for the development of R packages (no Java):
sudo dnf install R-core-devel -y
Install R with Fedora-provided Java Runtime Environment:
sudo dnf install R-java -y
Install the development package for use with Java-enabled R components:
sudo dnf install R-java-devel -y
Install the standalone math library from the R project:
sudo dnf install libRmath -y
Install the headers from the R standalone math library:
sudo dnf install libRmath-devel -y
Install R Packages from CRAN
Now that R is installed on your system, you can launch the R terminal instance.
In your terminal, use the following command.
sudo -i R
Example out R terminal:
R has quite an extensive range of packages that you can install. For the tutorial, the “txtplot” package returns ASCII graphs with “line plot, scatter plot, bar charts, and density plot.” This is installed by using the install.packages(”) command in R’s terminal shell.
With “textplot” now installed, you can run a test by activating the package in the R shell terminal.
Next, an example is shown by using the example data supplied by R’s “datasets” package, with contains the speed of cars and the distance required to stop based on data from the 1920s.
txtplot(cars[,1], cars[,2], xlab = 'speed', ylab = 'distance')
From this input command, you will then receive a plot graph.
Additionally, you can use the following command to get help on the packages installed.
Replace “package name” with the package installed. In the tutorial’s case, this was “txtplot”.
To remove a package or “txtplot”, use the following remove command in the R shell terminal.
To exit the R shell terminal interface, use the “q()” command.
You will see the following prompt:
Save workspace image? [y/n/c]:
Select your option to exit by typing y, n, or c and pressing the “ENTER KEY”.
How to Install R Packages from cran2copr
Optionally, you can install the following cran2copr. This project binary RPM has available the current and previous stable Fedora version for most of CRAN (more than 17k packages) in an automated way using Fedora Copr.
To install the RPM repository, use the following command.
sudo dnf install 'dnf-command(copr)'
Once installed, enable the cran2copr.
sudo dnf copr enable iucar/cran -y
Once cran2copr is enabled, install the Copr Manager as follows.
sudo dnf install R-CoprManager -y
Example of using Copr Manager in your R session.
To remove packages from your system library, you can use the remove.packages command. However, use the following example to remove the packages from your system when using Copr Manager.
If you want to disable the CoprManager, use the following command.
Next, install.packages work only with CRAN again, and you can begin to re-install as follows.
Comments and Conclusion
One of the best parts about R programming is that it is more of a community-run software, which means that anyone can provide code enhancements and new packages. The consistency in the R community environment is a testament to this approach to developing specific software by sharing and encouraging inputs. This tool is also compatible across platforms and runs on many operating systems and hardware.
Additionally, you can find more R packages at Available CRAN Packages By Name.