How To Install R on Debian 11

R is a programming language that is often utilized by statisticians because of its capabilities in statistical computing. In this tutorial we will describe how to install R on Debian 11.

Step 1: Update system

apt update
apt -y upgrade

Step 2: Install R on Debian 11

apt -y install r-base

Step 3. Test the Installation

Launch R.

R

To exit R, type:

q()

Then press ENTER. When prompted to save the workspace image, answer Y to save the workspace, N to exit without saving, or C to cancel and return to R.

Step 4. Install Packages

R packages extend the capabilities of R. Packages are only available to the user who installed them unless they are installed by the root user.

Start R.

R

Install the package. Replace example with the desired package.

> install.packages("example")

Here is a list of useful R packages.

A Demo with txtplot

The txtplot library can output many different kinds of charts in ASCII.

Start R.

R

Install the txtplot package.

> install.packages('txtplot')

Load the txtplot package.

> library('txtplot')

Plot the speed and distance required for a car to stop, using R’s default datasets package.

> txtplot(cars[,1], cars[,2], xlab = 'speed', ylab = 'distance')

The output looks like this:

Getting Help

Use the help command to learn more about a library. For example, to learn more about the txtplot library, run the following command.

> help(txtplot)

In this post you learned how to install R on Debian 11 Linux distribution.