Install R on Debian 10

Updated on November 21, 2023
Install R on Debian 10 header image

R is a programming language that is often utilized by statisticians because of its capabilities in statistical computing. This guide describes how to install R on Debian 10.

1. Prepare the Server

2. Install R

Install R from the standard repository.

$ sudo apt install r-base -y

3. Test the Installation

Launch R.

$ R

You should see output similar to:

R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

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.

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.

5. 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:

      +----+-----------+------------+-----------+-----------+--+
  120 +                                                   *    +
      |                                                        |
d 100 +                                                   *    +
i     |                                    *                *  |
s  80 +                          *         *                   +
t     |                                       * *    *    *    |
a  60 +                          *  *      *    *      *       +
n     |                        *         * *  * *              |
c  40 +                *       * *    *  *    * *              +
e     |         *      *  * *  * *  *                          |
   20 +           *    *  * *       *                          +
      |  *      *    *                                         |
    0 +----+-----------+------------+-----------+-----------+--+
           5          10           15          20          25   
                                speed                           

6. 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)

Conclusion

R is extremely powerful and has a steep learning curve. A good place to get started is from the official project help page.