R Programming Language on Fedora Linux 35

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.

In the following tutorial, you will learn how to install R on Fedora Linux 35.

Update Fedora System

Update your Fedora operating system to make sure all existing packages are up to date:

sudo dnf upgrade --refresh -y

Install Dependencies Required

Before installing, run the following command to install or check that the package dnf-plugins-core is installed on your Fedora desktop.

sudo dnf install dnf-plugins-core dnf-utils dnf-plugin-config-manager -y

Install R Programming Language

By default, 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

Example output:

How to Install R Programming Language on Fedora 35

Type Y, then press the ENTER KEY to proceed and complete the installation.

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.

R --version

Example output:

How to Install R Programming Language on Fedora 35

Alternative Install Options

As first 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:

How to Install R Programming Language on Fedora 35

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.

install.packages('txtplot')

Example output:

How to Install R Programming Language on Fedora 35

With “textplot” now installed, you can run a test by activating the package in the R shell terminal.

library('txtplot')

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.

Example:

How to Install R Programming Language on Fedora 35

Additionally, you can use the following command to get help on the packages installed.

help(package name)

Replace “package name” with the package installed. In the tutorial’s case, this was “txtplot”.

Example:

help(txtplot)

To remove a package, or “txtplot” use the following remove command in the R shell terminal.

remove.packages('txtplot')

To exit the R shell terminal interface, use the “q()” command.

q()

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 as of Aug. 2021) 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.

install.packages("car")
update.packages(ask=FALSE)

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.

CoprManager::remove_copr("car")

If you want to disable the CoprManager, use the following command.

CoprManager::disable()

Next, install.packages work only with CRAN again, and you can begin to re-install as follows.

install.packages("car")

Comments and Conclusion

In the tutorial, you have learned how to install R on Fedora 35 by using the CRAN repository, which you can draw upon packages and updates frequently.

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 thereby it runs on many operating systems as well as hardware.

Additionally, you can find more R packages at Available CRAN Packages By Name.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!