2. R and RStudio

R is a high-level interpreted programming language used in many modules with a statistical component. RStudio is an integrated development environment (IDE) for R, providing editing, debugging and much more.

Note that it is not necessary to have RStudio in order to use R, but RStudio is highly recommended.

Also note that in most of the cases below (excluding the approach using Software Hub), R must be installed before trying to install RStudio.

2.1. Installing R and RStudio on Windows

2.1.1. Software Hub

Navigate to the Software Hub, scroll down to RStudio (or type it in the search box) and click Launch. The RStudio on Software Hub also includes R so you don’t need to install it separately.

Further information on using the Software Hub is available on the Imperial ICT Software Hub webpage.

2.1.2. Direct install

The current version of R can be obtained from the Comprehensive R Archive Network Windows download page. The click on the latest release link (it will be called something like Download R 4.0.2 for Windows, but the version may be newer than that). Run the installer and accept all of the default options.

RStudio can be installed from the RStudio install page. Usually the big blue button will automatically detect the right version. Again, run the installer and accept the default options.

2.1.3. Running RStudio

Simply type rstudio in the search box at the bottom left of your screen.

_images/rstudio.png

2.2. Installing R and RStudio on Mac

2.2.1. Homebrew

The easiest way to install R and RStudio on Mac is to install Homebrew and then run the following commands in the terminal:

$ brew cask install r
$ brew cask install rstudio

2.2.2. Direct install

The current version of R can be obtained from the Comprehensive R Archive Network Mac download page. The click on the latest release link (it will be called something like R-4.0.2.pkg, but the version may be newer than that). Run the installer and accept all of the default options.

RStudio can be installed from the RStudio install page. Usually the big blue button will automatically detect the right version. Again, run the installer and accept the default options.

2.2.3. Running RStudio

You launch RStudio by pressing + space to open Spotlight search and type rstudio in the resulting search box:

_images/spotlight-rstudio.png

2.3. Installing R and RStudio on Linux or Chrome OS 1

It’s likely that your Linux distribution ships a suitable version of R. For example on Ubuntu you would run:

$ sudo apt install r-base

On Fedora you would run:

$ sudo dnf install R

There are further details about installing R for various Linux distributions on the Comprehensive R Archive Network Linux folder.

You next need to download the RStudio package for your distribution from the RStudio install page. Once again, the install mechanism depends on the distribution. For Fedora and related packages, you may be able to simply double click on downloaded .rpm file. This might also work with the downloaded .deb file for Ubuntu, but you can also do it in the terminal by running the following command in the folder containing the downloaded .deb:

$ sudo apt install <deb_file>

Obviously you replace <deb_file> with the name of the .deb file.

Footnotes

1

To use these installation instructions for Chrome OS you first need to set up Linux on your Chromebook.