Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔄 Update "How To Install R on Debian" #912

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
SPDX-License-Identifier: MIT
path: "/tutorials/how-to-install-r-on-debian-10"
slug: "how-to-install-r-on-debian-10"
date: "2019-08-09"
title: "How To Install R on Debian 10"
short_description: "This tutorial explains how to install the programming language R on Debian 10"
path: "/tutorials/how-to-install-r-on-debian"
slug: "how-to-install-r-on-debian"
date: "2024-08-20"
title: "How To Install R on Debian"
short_description: "This tutorial explains how to install the programming language R on Debian"
tags: ["Linux", "R", "Debian"]
author: "Roland Balla"
author_link: "https://github.com/broland07"
Expand All @@ -24,26 +24,21 @@ R is an open-source programming language, that is widely used for developing sta

To follow along with this tutorial, you will need a Debian 10 server with:

* at least 1GB of RAM
* a non-root user with sudo privileges
* At least 1GB of RAM
* A non-root user with sudo privileges

## Step 1 - Installing Dependencies

Because 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. In order to do this, we’ll need to install some dependencies for the Debian 10 cloud image.
Because 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. In order to do this, we’ll need to install some dependencies for Debian.

To perform network operations that manage and download certificates, we need to install dirmngr so that we can add the external repository.
To perform network operations that manage and download certificates, we need to install `dirmngr` so that we can add the external repository.

```bash
sudo apt update
sudo apt install dirmngr --install-recommends
```

To add a PPA reference to Debian, we’ll 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`:

```bash
sudo apt install software-properties-common
```

Finally, to ensure that we have HTTPS support for secure protocols, we’ll install the following tool:
To ensure that we have HTTPS support for secure protocols, we’ll install the following tool:

```bash
sudo apt install apt-transport-https
Expand All @@ -55,39 +50,50 @@ With these dependencies in place, we’re ready to install R.

For the most recent version of R, we’ll be installing from the CRAN repositories.

> [List of available mirrors](https://cran.r-project.org/mirrors.html)

Let’s first add the relevant GPG key.

```bash
sudo apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'
sudo gpg --keyserver keyserver.ubuntu.com --recv-key '95C0FAF38DB3CCAD0C080A7BDC78B2DDEABC47B7'
sudo gpg --armor --export '95C0FAF38DB3CCAD0C080A7BDC78B2DDEABC47B7' | sudo tee /etc/apt/trusted.gpg.d/cran_debian_key.asc
```

Once we have the trusted key, we can add the repository.

```bash
sudo add-apt-repository 'deb https://ftp.fau.de/cran/bin/linux/debian buster-cran35/'
```
* Debian 11
```bash
echo "deb http://cloud.r-project.org/bin/linux/debian bullseye-cran40/" | sudo tee -a /etc/apt/sources.list
```

* Debian 12
```bash
echo "deb http://cloud.r-project.org/bin/linux/debian bookworm-cran40/" | sudo tee -a /etc/apt/sources.list
```

Now, we’ll need to run an update after this in order to include package manifests from the new repository.

```bash
sudo apt update
```

Once this completes running and you’re returned to your prompt, we’re ready to install R with the following command.
Once this completes running and you’re returned to your prompt, check if the latest version of `r-base` is now available. If it is, we’re ready to install R with the following command.

```bash
sudo apt-cache policy r-base
sudo apt install r-base
```

If prompted to confirm installation, press y to continue.
If prompted to confirm installation, press `y` to continue.

As of the time of writing, the latest stable version of R from CRAN is 3.6.1, which is displayed when you start R.
As of the time of writing, the latest stable version of R from CRAN is 4.4.1, which is displayed when you start R.

Since we’re planning to install an example package for every user on the system, we’ll start R as root so that the libraries will be available to all users automatically. Alternatively, if you run the R command without sudo, a personal library can be set up for your user.

```bash
sudo -i R
```

This confirms that we’ve successfully installed R and entered its interactive shell.

## Step 3 - Installing Add-on Packages from CRAN
Expand Down