This article is a guide on how to install R and RStudio on Ubuntu 22.04; let’s begin:
How to install R and RStudio on Ubuntu 22.04
In this tutorial, we will provide you step by step guidance to install R and RStudio on your Ubuntu 22.04 . Each step includes different commands which need to be executed to successfully run R and RStudio on Ubuntu 22.04. Let’s start discussing each step.
Step 1: First, you will require to update the packages list using the following commands:
$ sudo apt upgrade
Step 2: Next, you must download the essential dependencies used for running R on Ubuntu 20.04 . This can be done through following command:
Step 3: After installing the required dependencies now to authenticate package, use:
Step 4: Add the CRN repository using the following command:
Step 5: Once the above installation is completed, you can now run the R installation using the command.
If you encounter the libicu66 package error while installing R, you need to download the libicu66 package from the website. Once it is downloaded, go to the directory of the downloaded deb package using the following command.
You can install the package using the below given command.
When the package installation is completed, you can then rerun the R installer again, and this time it will be installed on your Ubuntu 22.04 desktop.
Step 6: To check the R version, use the following command.
Step 7: In the next step, let’s start running a simple R program to test whether the environment is working fine. We will use the txtplot library to output a graph which includes scatter plot, line plot, bar plot and much more.
First, use the “R” command in the terminal to run the R environment and then use the following command to install txtplot.
Then load the textplot in R as:
Once the txtplot is loaded, execute the following code below to output a graph.
You can also add labels to the x and y axis using the following command.
This ensures that R is up and running on your Ubuntu 22.04 desktop. You can now write, text, and execute other codes of R programming language. You can find other codes from the GitHub website.
How to install RStudio on Ubuntu 22.04
RStudio is an IDE used for running codes written in R language. To install RStudio on Ubuntu 22.04, you will require the following steps.
Step 1: Execute the following command to download the RStudio deb package on Ubuntu 22.04.
Step 3: Now use the following command to run the RStudio installation using dpkg.
This will install RStudio on Ubuntu. Use the “rstudio” command in the terminal to run it or find it in the applications.
R is a widely used programming language adopted mainly by data scientists to perform different operations like data analysis, graphics, statistical commutating, and more. The above installation steps will aid you in installing R on your Ubuntu 22.04 desktop and then you can write and execute different codes written in R language directly onto the terminal.