![](images/banner.png)
Chapter1 Installing R and RStudio
R and RStudio are two distinct pieces of software. R is a programming language, primarily used in fields such as statistics. RStudio, on the other hand, is a user-friendly interface and an Integrated Development Environment (IDE) specifically designed for R programming language (i.e., to facilitate the use of R). While R can be used on its own (i.e., with a Console alone), it is generally recommended to work with it through RStudio. Both need to be installed separately, and the installation process varies depending on the operating system (Windows, macOS, or Linux). We provide instructions only for Windows, macOS, and Linux (Ubuntu). Of course, R is available for all major Linux distributions. The instructions provided for Ubuntu (the most popular distribution) are also applicable to its derivative distributions.
1.1 Installing R
- Go to the website: https://www.r-project.org
- Select CRAN (Comprehensive R Archive Network) from the left-hand menu under Download
![](images/install_CRAN.png)
- Select the first link: https://cloud.r-project.org/
![](images/install_mirror.png)
- Select your operating system
![](images/install_OS.png)
1.1.1 R Windows
- Select base
![](images/install-Windows-base.png)
- Select Download for the latest available version of R
![](images/install-Windows-version.png)
- Once the download is complete, run the file and follow the instructions until the installation is finished
1.1.2 R MacOS
- Select the latest available version of R
![](images/install_Mac_version.png)
- Once the download is complete, run the file and follow the instructions to complete the installation of R
- Next, you will also need to install an additional component XQuartz by clicking the link within the orange box shown in the previous figure
- Select Download
![](images/install_Mac_XQuartz.png)
- Once the download is complete, run the file and follow the instructions to finish the installation
1.1.3 R Linux
Despite the ease of installing packages on Linux, R can sometimes be more complicated to install due to the variety of distributions, repositories, and keys required to recognize the repository as secure.
On CRAN there is an official guide with all the apt
commands to run from the terminal. By following these steps, there should be no issues.
- Go to CRAN
- Click
Download R for Linux
- Select your distribution (Ubuntu in this case)
- Follow the instructions, mainly running the suggested terminal commands
For any difficulties or errors, especially in the Linux environment, an online search usually resolves the issue.
1.2 Installing R Studio
Go to the website https://posit.co/download/rstudio-desktop/ and download RStudio Desktop for your operating system
Once the download is complete, run the file and follow the instructions to finish the installation
1.2.1 R Studio on Linux
In this case, as with Windows and macOS, the installation consists of downloading and running the correct file, depending on the distribution (for example, .deb
for Ubuntu and derivatives). Importantly, in the case of Ubuntu (but this should apply to other distributions as well), even versions later than the one indicated (e.g., Ubuntu 16) are fully compatible.