Introduction

R is the name of both:

  • the R programming language, i.e. the language you use to tell the PC what computations to perform; and
  • the R interpreter, which actually executes the computations written in the R language.

RStudio is a user-friendly interface around R that makes the programming experience much nicer. It bundles together

  • a file editor panel,
  • a console panel with the R interpreter,
  • an environment panel showing all the objects you have created
  • a files and plots panel to see your PC files and the plots you create.

The programming language R comes with built-in functionality, like computing the square root with the sqrt() function. Over the years, R users have created lots of additional functionalities that is available on demand. If you particular application requires extra functionality not available with the basic R installation, you can add it by installing packages. A package is an additional bit of functionality and it needs to be installed only once to bring it from the web to your own R installation. However, it is also important to keep packages updated once or twice a year.

This document explains how to

  1. install R and RStudio, if you never used them before;
  2. update R and RStudio, if you have old versions;
  3. how to update your R packages.

A. Installing R and RStudio

Windows PC

  1. If you have a previous R installation, please uninstall the following software from your PC if you have it:
    • R
    • Rtools
    • RStudio
  2. Install R
  3. Install RTools
  4. Install RStudio
    • Go to https://posit.co/download/rstudio-desktop/, ignore the “install R” stuff (you’ve done that already). In the table of RStudio installers, find the one for your operating system and download it.
    • Open the installer and follow the instructions while keeping the default options.

Apple macOS PC

  1. If you have a previous R installation, please uninstall the following software from your PC if you have it:
    • R
    • XQuartz
    • RStudio
  2. Install R
    • Check which Apple PC you have. On the top-left of your screen click the Apple logo, click About This Mac, note what the Processor line says.
    • Go to https://cran.r-project.org/bin/macosx/ and download:
      • R-4.4.0-x86_64.pkg if you have an Intel-based macOS PC
      • R-4.4.0-arm64.pkg if you have an Apple silicon arm64 macOS PC.
    • Open the installer and follow the instructions while keeping the default options.
  3. Install XQuartz
    • Download XQuartz: https://www.xquartz.org/
    • Open the installer and follow the instructions while keeping the default options
  4. Install RStudio
    • Go to https://posit.co/download/rstudio-desktop/, ignore the “install R” stuff (you’ve done that already). In the table of RStudio installers, find the one for your operating system and download it.
    • Open the installer and follow the instructions while keeping the default options.

Chromebooks/Ipads etc

You cannot install R or RStudio on Chromebooks or Ipads.
However, you can use RStudio on the PPLS Server.

First try these steps:

  1. Log in to EASE using your university UUN and password

  2. Set your RStudio password here, the username will be the same as your UUN (make sure you type your UUN correctly!)

  3. Access the server from https://rstudio.ppls.ed.ac.uk using your university UUN and the password you set above in (2).

If that didn’t work:

Please fill out this form and wait for an email from us with instructions.

B. Updating R and RStudio

B.1 Updating R

If your R version or packages are old, you might get errors or find that the code required to run some examples is different from the one provided.

Recall that R is the underlying programming language, while RStudio is just a wrapper around R providing a nicer user interface (text editor, file explorer and graphical window). Updating RStudio (the interface) will not update the R programming language which runs your code.

Check which R version you have

Check that your R version is up-to-date by typing into the R console:

version

After pressing Enter, you should see something like this:

platform       << this will be different for each of you >>     
arch           << this will be different for each of you >>                  
os             << this will be different for each of you >>     
system         << this will be different for each of you >>        
status                                     
major          4                           
minor          4.0                         
<< and more lines which you can ignore... >>

Please check here: https://www.r-project.org/ to see what the most recent version is. If you have a different number for “major” than the most recent, it may well be time for an update.

Updating R

Windows PC

Open RStudio, and type the following in the R console. Press Enter to run the code.

install.packages("installr")
installr::updateR()

Apple macOS PC

  1. Follow step 2 from the instructions in section A in order to install the newest version of R.
  2. In RStudio, look in the top menu for Tools > Global Options. In the “R General” tab, you can choose which option of R you want to use. Make sure this is set to the one you just downloaded.

B.2 Updating RStudio

Check if you need to update RStudio by clicking Help and then Check for updates.

If an update is available, follow step 4 in section A.

C. Updating R packages

Open RStudio. In the R console, type the following and press Enter:

options(pkgType = "binary")
update.packages(ask = FALSE)

History

  • Last updated by UN in May 2024 for R version 4.4.0
  • Last updated by UN in September 2023 for R version 4.3.1
  • Last updated by UN in November 2022 for R version 4.2.2
  • Last updated by UN in July 2022 for R version 4.2.1

Department of Psychology
The University of Edinburgh