How to Install RStudio and R on Ubuntu 22.04

The “R” is the programming language used to create graphic programs and some statistical programs. In contrast, RStudio creates software for data science and technical communication and is not functional without R (while R can run separately). This post will address the methods to install  “R” and “RStudio” on Ubuntu.

How to Install RStudio on Ubuntu 22.04?

Follow the below-mentioned steps to download and install the RStudio on Ubuntu:

Step 1: Download the RStudio

For the installation of RStudio, download the official Debian package of RStudio using the command:

$ wget -c https://download1.rstudio.org/desktop/jammy/amd64/rstudio-2022.07.2-576-amd64.deb

Step 2: Install the RStudio

After downloading the Debian package from its official website, we will install it using the dpkg manager on Ubuntu:

$ sudo dpkg -i rstudio-2022.07.2-576-amd64.deb

Launch the RStudio

Once the RStudio is installed, you can launch it through the command provided below:

$ rstudio

The GUI of RStudio will be launched after the execution of the above command:

The RStudio is installed successfully and ready to use.

How to Install R on Ubuntu 22.04?

The “R support is provided through an external repository verified by a public key. Let’s perform the following steps to install R on Ubuntu 22.04

Step 1: Add the Key

In Linux; some packages are added to third-party sources. These third-party may secure their packages with some public keys; therefore, to download such repositories, we have first to add their public keys. For the installation of “R” on Ubuntu, first, add the public key using the command:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9

Step 2: Add the Repository

Then, add the repository of R from the cran using the command:

$  sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/'

Press the “ENTER” key of the keyboard to proceed with the step of adding the repository of “R”.

Step 3: Install R

When this step is completed, then install the “R” using the command:

$ sudo apt install r-base -y

Verify the Version

On completion of the installation, run the command to display the installed version of “R”:

$ sudo -i R

The package of the “R” has been successfully installed and is ready to use.

How to Uninstall RStudio and R on Ubuntu 22.04?

To uninstall the R and RStudio, remove them with the apt package manager:

$ sudo apt remove  rstudio r-base -y

Then use the auto-remove command to remove all the other files associated with the packages of rstudio and r-base:

$ sudo apt auto-remove -y

Conclusion

To install “R” and RStudio, run the commands,”sudo apt install r-base -y” and “sudo dpkg -i <Package Name>” respectively. In this blog, installation methods of both “R” and “RStudio” have been demonstrated in detail. The installation of “R” is carried out by adding the repository whereas to install the “RStudio”, its Debian package file is required. You have learned the installation of R and RStudio on Ubuntu 22.04.