R is a programming language extensively used in statistics. This guide explains how to install R on a cloud server running Ubuntu or Debian operating systems.
To install R, you only need to execute the following command.
$ sudo apt install r-base -y
To enter the R environment, run the R command.
$ R
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 the R environment, execute q() and press Enter.
> q()
R packages enhance the capabilities of the R language. Here's how to install an R package. Replace "txtplot" with the actual name of the package.
$ R
> install.packages('txtplot')
> library('txtplot')
> txtplot(cars[,1], cars[,2], xlab = 'speed', ylab = 'distance')
The output is as follows:
+----+-----------+------------+-----------+-----------+--+
120 + * +
| |
d 100 + * +
i | * * |
s 80 + * * +
t | * * * * |
a 60 + * * * * * +
n | * * * * * |
c 40 + * * * * * * * +
e | * * * * * * * |
20 + * * * * * +
| * * * |
0 +----+-----------+------------+-----------+-----------+--+
5 10 15 20 25
speed
To get help on a package, use the help command. For instance, to get help on the txtplot package, run the following command.
> help(txtplot)
23-02-2024 02:02:07
22-02-2024 03:19:32
22-02-2024 03:16:03
22-02-2024 03:14:03
22-02-2024 03:11:58