R Language Download For Ubuntu
R is an open-source programming language that is used in analyzing and implementing data and statistical computing. It is a very popular and extensible language support by R foundation and an active user community. R language provides a lot of user packages for various fields of study. I will show you how to install the R framework and how to add packages to it from the official CRAN network.
Step 1:
As always, first, update your APT.
Step 2:
Now, upgrade your APT.
Step 3:
As the R project is updated regularly, that is why its latest stable version is not present on Ubuntu official repositories; for this purpose, we will be adding an external repository to the APT package manager. Add a GPG key to your APT package manager via the following terminal command.
$ sudo apt-key adv --keyserver keyserver.ubuntu.com
--recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
Step 4:
Now that you have added the repository key to your APT, you can continue with adding the deb repository for the R language. At present, the latest package for Ubuntu 20.04 is R 4.0.0, so the command will contain "cran40" at the end. You can check for the latest package via the CRAN official website.
$ sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu
focal-cran40/'
Step 5:
Now update your APT again for letting the changes take effect.
Step 6:
Now, you are ready to install the R base file on your Ubuntu machine.
$ sudo apt install r-base
You will be prompted with a yes/no condition, press y to install the package.
Step 7:
Now, you are ready to install various packages with the help of R. For that purpose. We will start R with the following terminal command, which will open the R shell in the terminal window.
Step 8:
There are a lot of packages and libraries present for R, and we will be selecting the "txtplot" package that returns ASCII graphs with "line plot, scatter plot, bar charts, and density plot." Execute the following command inside the R shell.
> install.packages('txtplot')
As we have started R with root privileges so the location of the package will be available to all users.
Step 9:
Now, start the "txtplot" library via the following shell command.
This will load the txtplot library, and you can start using it. We will be using the following example to show you a basic overview of plotting. The data used in this plot will contain the distance required to stop a car and the speed of a car.
> txtplot(cars[,1 ], cars[,2 ], xlab = 'speed', ylab = 'distance')
This command will present you with a plot graph as given in the following window.
Step 10:
You can also learn more about the txtplot library by using the following R shell command to show the manual.
Step 11:
Any package present in the CRAN network can be installed using the "install.packages()" command. you can find all the available packages in CRAN official package list. You can exit R shell by the following shell command.
Type 'n' when prompted with a yes/no condition to exit the R shell.
Conclusion:
We have covered how to install R latest stable version on Ubuntu 20.04 and how to install packages via the R shell.
About the author
I am a freelancing software project developer, a software engineering graduate and a content writer. I love working with Linux and open-source software.
Posted by: terrellalthausss.blogspot.com
Source: https://linuxhint.com/install_r_ubuntu/
Komentar
Posting Komentar