1 R and RStudio

Welcome to Level 2 Statistics! Today you will be introduced to R and RStudio and learn how to download and install them on to your device.

R is a programming language that you will use to write code in numerous statistics courses throughout your degree. RStudio is an accompaniment to R, known as an Integrated Development Environment (IDE). RStudio essentially makes all features of the R programming language easier to use and it is the software you will interact with, rather than R directly.

It is best for you to install R and RStudio on your own device and use this throughout your courses.

If you do not already have R and RStudio downloaded on your device, follow the steps outlined below in Sections 1.1 and 1.2 before moving on to Section 3 which will detail how to use RStudio. If you are unable to install R or RStudio on to your own device, or are using a tablet, look at section 2 for some alternative ways to use R and RStudio.

1.1 Installing R

R logo

The first step is to install R onto your device. This can be done for free from CRAN (the Comprehensive R Archive Network). R is available for Windows, Mac OS, Linux and some other less common operating systems.

  • If you are using a Windows device, follow this link and click 'Download R-4.3.1 for Windows' to download the installer for the latest version of R. Once this is complete, run the installer and accept all default settings.
  • If you are using a Mac, follow this link and select the .pkg file from the left of the screen to download the installer for the latest version of R. Make sure to choose the one applicable for the chip your Mac uses (you can check what chip is used by going to  > About This Mac). Once the download is complete, open the file and complete the onscreen steps to finish installing R.

1.2 Installing RStudio

RStudio logo

Now that R is installed on your device, you are ready to download and install RStudio.

To do this, follow the link to RStudio and click on the link 'Download RStudio...'. This should automatically detect what system your device is using but make sure to double check it says either for Windows or for MacOS - whichever is correct!

This file may take a while to download, but once it has launch the installer and follow the steps to complete the installation.

You are now ready to use RStudio. Make sure you launch the RStudio app to work within, rather than R.

1.3 Updating R and RStudio

Both R and RStudio are updated occasionally. It is important to use an up-to-date version of both so that everything runs smoothly.

If you already have R and RStudio installed on your device, check what version of each you are using in an open RStudio app window.

  • You can find the version of R you are using by running the code below in RStudio (see section 3 to learn how to run code). The first line this shows in the console pane will say something like R version 4.3.1.

    If the version of R you have installed is below version 4.2.0, then use section 1.1 above to install an updated version (if you are using a Windows device, you might first need to uninstall R before updating it).

sessionInfo()
  • You can find the version of RStudio you are using by going to Help > Check for Updates at the very top of the RStudio window. If an update is available, then use section 1.2 above to install an updated version.