As system administrators and IT group personnel we must always look for the best tools that allow us to have centralized and direct control over everything that happens in the system. There are hundreds of tools each with its level of functionality or display of results and for this reason TechnoWikis will talk about a special one called R which has been created in order to focus on everything associated with computation and statistical graphics ..
What is r
R is a language and environment specially designed, as we mentioned, for computation and statistical graphics., As such it is a GNU project similar to the language and environment S, which was developed at Bell Laboratories because much of the code written for S runs unchanged under R, but R has notable differences against S.
By using R, we have a utility that generates various statistical techniques such as linear and nonlinear modeling, classic statistical tests, time series analysis, classification, grouping and graphs, being fully extensible to increase your deployment capacity.
R has the ability to create quality results where mathematical symbols and formulas can be included if required.
R is available as Free Software under the terms of the GNU General Public License and is available for UNIX platforms including FreeBSD and Linux), Windows and MacOS ..
1. R environment and installation Ubuntu 18.04
R itself is an integrated set of software installations created for data manipulation, calculation and graphic display, including parameters such as:
- Effective installation of data management and storage
- Graphic installations for data analysis and visualization on screen or in hard copy of these
- It has a set of operators for matrix calculations, a large and integrated collection of intermediate tools for data analysis
- It is compatible with conditional, loops, user-defined recursive functions and input and output facilities.
Due to the constant updates of R, we will add the external repository maintained by CRAN, CRAN maintains the repositories within the network, but not all external repositories are reliable.
The first step for the installation of R in Ubuntu 18 is to add the GPG key which will be possible using the following line:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
Now, we will add the official repository by running the following:
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35 /'
Once the repository is added, we proceed to update the repository packages by executing the following:
sudo apt update
2. How to install R on Ubuntu 18.04
After updating the packages, we can start the installation of R, for this we will execute the following command:
sudo apt install r-base
Enter the letter S to confirm the download and installation of R in Ubuntu 18..
Step 2
Once R is installed on Ubuntu 18, we will verify its use by running an interactive session as root users with the following command:
sudo -i R
We can see that everything works the right way, there we can execute the demo command to see a sample of how R. works.
3. How to install packages using CRAN on Ubuntu 18.04
R is an application that has a large number of complementary packages available, for this case we are going to install txtplot, which is a library that generates ASCII graphics that include scatter diagrams, line diagrams, density diagrams, acf and graphs of bars.
To do this, we will execute the following line in the R console:
install.packages ('txtplot')
We can see that the validation and installation process begins.
Once installed we will load the installed package. If there are no error messages, it means that the library was loaded correctly.
library ('txtplot')
Now we will use an example where a plot function with axis labels is demonstrated. The data to be used, are provided by the R data set package, which contains the speed of the cars and the necessary distance to stop based on the data of the 1920s, we execute the following:
txtplot (cars [, 1], cars [, 2], xlab = 'speed', ylab = 'distance')
Thus, any precompiled package can be installed from CRAN with the install.packages () syntax.
CRAN has more than 2000 packages available, to know in detail what is the function of each of them and how to install it, we can go to the following CRAN link:
CRAN packages
In this way, R becomes a practical utility for installing packages and for viewing different types of metrics in Linux.