Jun 13, 2023 4 min read

How to Install R on Debian 10

Install R on Debian 10 with our step-by-step tutorial. R is a free and open-source programming language that focuses on statistical computing.

 Install R on Debian 10
Table of Contents

Choose a different version or distribution

Introduction

Before we begin talking about how to install R on Debian 10, let's briefly understand – What is R?

"R" is a programming language widely used in statistical computing and data analysis. It provides a comprehensive set of tools for manipulating, visualizing, and modeling data. With its user-friendly interface and vast collection of packages, R is ideal for data scientists, statisticians, and researchers.

Whether you're exploring data, building predictive models, or creating data visualizations, R is a powerful and versatile tool that can help you uncover valuable insights and make data-driven decisions. Discover the capabilities of R and unleash the potential of your data analysis.

In this tutorial, you will install R on Debian 10. We will also address a few FAQs on how to install R on Debian 10.

Advantages of R

  1. Versatile: R offers a vast array of packages for diverse data analysis tasks.
  2. Data Visualization: R provides powerful tools to create visually appealing and informative data visualizations.
  3. Statistical Analysis: R has extensive statistical capabilities for conducting advanced analyses.
  4. Community Support: R benefits from an active and supportive user community, ensuring prompt assistance and shared knowledge.
  5. Integration: R seamlessly integrates with other programming languages and tools, enabling efficient data workflows and collaborations.

Prerequisites to Install R on Debian 10

Before proceeding with this tutorial, make sure you have the following criteria met:

  • A Debian 10 machine with at least 1 GB of RAM is required. You can make a swap file if your system has less than 1 GB of RAM.
  • You have access as a user with sudo privileges.

Install R on Debian

In the Debian repositories, the R packages are usually out of date. R will be installed from the CRAN repository.

Follow the following steps to install R on Debian 10:

The following steps demonstrate how to install the latest stable version of R on Debian 10:

1) Install the essential packages, so you can create a new repository over HTTPS:

sudo apt install dirmngr apt-transport-https ca-certificates software-properties-common gnupg2

2) To enable the CRAN repository and add the CRAN GPG key to your system, run the commands below:

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/'

3) Install the R package and update the packages list:

sudo apt update
sudo apt install r-base

4) Print the R version to confirm the installation:

R --version

The most recent stable version of R is 3.6.3 as of the time this article was written.

Output

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

The extensive selection of packages made available by the Comprehensive R Archive Network (CRAN) is one of the key factors contributing to R's popularity.

Install the build-essential package, which contains the necessary tools for compiling R packages:

sudo apt install build-essential

The packages are installed globally and made accessible to all users of the system if the R binary is launched as root or sudo users. Invoke the binary as a regular user to create a personal library for your user.
 
As an example, we will install the stringr package, which offers quick and accurate implementations of popular string manipulations.

Launch the R console as root:

sudo -i R
Output

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.

> 

The R console is used to run the commands listed below.

Install the stringr package as follows:

install.packages("stringr")

It will take some time to install. Once finished, load the library:

library(stringr)

Build a basic character vector called tutorial:

tutorial <- c("How", "to", "Install", "R", "on", "Debian", "9")

Run the function that prints a string's length by doing as follows:

str_length(tutorial)
Output

[1] 3 2 7 1 2 6 1

More R packages are available on the CRAN Packages website. You can install them using the install.packages ().

FAQs to Install R on Debian 10

How can I check the installed version of R on Debian 10?

In the terminal, type R --version. It will display the installed R version and other information.

Can I install specific packages in R on Debian 10?

Yes, you can install packages using the install.packages("package_name") command within the R console.

Are there any additional repositories for R packages on Debian 10?

Yes, you can add the CRAN (Comprehensive R Archive Network) repository to access a vast collection of R packages.

Is there a command-line interface available for R on Debian 10?

Yes, R provides a command-line interface called R Console, which you can access by typing R in the terminal.

How do I upgrade R to the latest version on Debian 10?

To upgrade R to the latest version on Debian 10, run sudo apt update && sudo apt upgrade to update all installed packages, including R.

Conclusion

You now know how to install R on Debian 10 and how to install R packages.

If you have any queries, please leave a comment below and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.