Linux Mint

How to Install R and RStudio on Linux Mint 21

R is a programming language and software environment for statistical computing and graphics. To use the R programming language on a Linux system one can use the terminal or RStudio which is a separate integrated development environment (IDE) specifically designed for working with R. So, if you are looking to use R language then read this guide as it will discuss the detailed process for installing R and RStudio on Linux Mint 21.

How to Install R Language on Linux Mint 21

R programming language includes a wide range of statistical and graphical techniques and has a large and active community of users and developers. Here are some steps that one needs to follow to install r programming language on Linux Mint 21:

Step 1: To have trouble free installation it is a good practice to update the packages list of Linux Mint default package manager using:

$ sudo apt update

Step 2: Next, install all the dependencies required to run R programing language and for that execute:

$ sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common -y

Step 3: Now authenticate the dependences we installed in the previous step and for that execute:

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

Step 4: Next, get the CRAN repository for R language which contains R packages, documentation, and other resources related to the R programming language and for that execute:

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

Now to add the repository in the packages list of default packages manager update it by using:

$ sudo apt update

Step 5: Now install the R programing language on Linux mint by executing:

$ sudo apt install r-base -y

To confirm if this programing language is installed correctly check the version installed by executing:

$ sudo -i R

How to Use R Language on Linux Mint 21

Once you have installed R programming language on Linux Mint by following the above-mentioned steps, now for user understanding we have plotted some random value using R language in the steps below:

Step 1: First run the R language on Linux Mint; enter R in the terminal and then install packages for the txtplot commands using:

install.packages('txtplot')

Next continue the installation of the packages by entering yes:

Step 2: Once the library is installed, we have plotted random values up to 150 by executing:

a <- rnorm(150)

And to plot use:

plot(a)

So this is how one can use the R language to represent their data in the graphical form, further to quit working on this language just enter q() in the terminal, next to save the workspace image enter y:

How to Install RStudio on Linux Mint 21

RStudio is an integrated development environment (IDE) specifically designed for working with the R programming language. It is a popular and widely used tool among statisticians, data scientists, and other professionals who use R for statistical computing and data analysis, below are some steps to install it on Linux Mint 21:

Step 1: First download the RStudio deb file from its official website by selecting your Linux version that is Debian:

Step 2: Next, move to the directory where the file is downloaded, here in my case it’s in Downloads, so:

$ cd Downloads

And check the file presence using the command:

$ ls

Step 3: Now, install the RStudio on Linux mint 21 using its deb file we downloaded previously by executing:

$ sudo apt install ./rstudio-2022.07.2-576-amd64.deb -y

Now run the RStudio on Linux Mint 21:

$ rstudio

Further if you no longer need to work with R language then remove it completely from Linux Mint 21 through executing:

$ sudo apt remove --autoremove rstudio -y

Text Description automatically generated

Conclusion

R is a programming language and software environment for statistical computing and graphics, while RStudio is a separate integrated development environment (IDE) specifically designed for working with R. This guide covers the whole process in detail to install R language and RStudio on Linux Mint 21.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.