R is an open-source, widely used for developing statistical software and performing data analysis. It is supported by the R Foundation. This tutorial explains how to install R on Debian 10 Buster.
- You should logged in as root or user account with sudo privileges.
- Debian 10 system should have atleast 1 GB of RAM.
Installing R on Debian
R is a fast-moving project, the latest stable version isn’t always available from Debian’s repositories, so we’ll need to add the external repository maintained by CRAN.
Perform the following steps to install latest stable version of R on Debian:
First, you should install required dependencies to add new repository. Run following command to install dependencies:
sudo apt install dirmngr apt-transport-https ca-certificates software-properties-common gnupg2
Enable CRAN repository and add the CRAN GPG key to your system by issuing below command:
sudo apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/debian buster-cran35/'
Once the repository added you should update package list by typing:
sudo apt update
Next issue below command to install R on Debian:
sudo apt install r-base
Verify the installation by running the following command which will print the R version:
R version 3.6.3 (2020-02-29) -- "Holding the Windsock" Copyright (C) 2020 The R Foundation for Statistical Computing Platform: x86_64-pc-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/.
Install R Packages from CRAN
R is so popular because of wide availability of packages through the Comprehensive R Archive Network (CRAN). You should install
build-essential package which contains the tools required for compiling R Packages.
sudo apt install build-essential
We are going to install a stringr package for an example, which provides fast, correct implementations of common string manipulations.
Start by opening the R console as root:
sudo -i R
It will show as below:
R version 3.5.1 (2018-07-02) -- "Feather Spray" Copyright (C) 2018 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. >
stringr package, type:
Installation will take some time and after completion load library using:
Let’s create a simple vector named demo:
demo <- c("How", "to", "Install", "R", "on", "Debian", "10")
Now run the below command to print the length of a string:
 3 2 7 1 2 6 2
If you want to install more packages you can find it at CRAN Packages.
You have successfully learned how to install R on Debian 10 system.
If you have any problem or suggestion please leave a comment below.
Leave a Reply