How To Install And Configure R on Debian 9

R is open source programming language. It is very actively used as a development of statistical software and visualized. R offers many custom packages for various areas of study, making it applicable to many areas.

Install Dependencies

One thing to understand is that an external repository supported by CRAN should be added. For this, it is mandatory to install some dependencies, for Debian 9. First, install dirmngr in order to add an external repository

sudo apt install dirmngr --install-recommends

Then you need to add a link to PPA in Debian, we need to use the add-apt-repository command For installations where this command may not be available, you can add this utility to your system by installing software-properties-common:

sudo apt install software-properties-common

To support HTTPS (443 protocols), you must install the following

sudo apt install apt-transport-https

R Installing

First you need to add the corresponding GPG key

sudo apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'

After the command is run, the following will appear

Output
Executing: /tmp/apt-key-gpghome.k3UoM7WQGq/gpg.1.sh --keyserver keys.gnupg.net --recv-key E19F5F87128899B192B1A2C2AD5F960A256A04AF
gpg: key AD5F960A256A04AF: public key "Johannes Ranke (Wissenschaftlicher Berater) <johannes.ranke@jrwb.de>" imported
gpg: Total number processed: 1
gpg:               imported: 1

After the key has been received, add the repository. Note that if you are not using Debian 9 (Stretch), you can see the supported Debian R Project branches named for each release. You can find and familiarize yourself here: https://cran.r-project.org/bin/linux/debian/#supported-branches

sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/debian stretch-cran35/'

Next, run update. This is necessary to enable package manifests

sudo apt update

Next, approximately the following lines will be displayed:

Output…

Get:6 https://cloud.r-project.org/bin/linux/debian stretch-cran35/ InRelease [4,371 B] Get:7 https://cloud.r-project.org/bin/linux/debian stretch-cran35/ Packages [50.1 kB] …

Now you are ready to install R using the following command

sudo apt install r-base

Install R packages from CRAN

You need to install txtplot the library. It displays ASCII plots including scatter plot, line plot, density plot, acf plot and histograms:

install.packages('txtplot')

Here is the conclusion where exactly the package will be installed

Output…
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
. . .

After installation, we need to download txtplot:

library(‘txtplot’)

Then look, if there are no error messages, the library was loaded successfully!

So that you can get out of R, you can type q (). If you do not want to save the image of the workspace, you can press n.

Was this article helpful?

Related Articles

Leave A Comment?