What is R? What is RStudio?

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

A.1 Installing R

Windows PC

Uninstall any previous installations

If you have a previous R installation, please uninstall the following software from your PC if you have it:

  • R
  • Rtools
Install R

Download the installer: https://cran.r-project.org/bin/windows/base/R-4.4.3-win.exe

Open the installer and follow the instructions.

Install RTools

Download RTools:

Open the installer and follow the instructions.

Apple macOS PC

Uninstall any previous installations

If you have a previous R installation, please go to the Applications folder in your Finder window and move the following applications to the Bin:

  • R
  • XQuartz
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. If it has the word “Intel”, you want to follow 1 below, and 2 otherwise.

  1. Download this if you have an Apple M1-M4 macOS PC: https://cran.r-project.org/bin/macosx/big-sur-arm64/base/R-4.4.3-arm64.pkg

  2. Download this if you have an older Intel-based macOS PC: https://cran.r-project.org/bin/macosx/big-sur-x86_64/base/R-4.4.3-x86_64.pkg

Open the installer and follow the instructions.

Install XQuartz

Download XQuartz: https://xquartz.macosforge.org/.

Open the installer and follow the instructions.

Chromebooks

You cannot install R on Chromebooks. You can use Posit Cloud (https://posit.cloud/) for free for up to 25 hours per month.

A.2 Installing RStudio

Windows PC

Go to https://posit.co/download/rstudio-desktop/ and, under section “2: Install RStudio”, click the big blue “Download RStudio Desktop” button.

Open the installer and follow the instructions.

Apple macOS PC

Go to https://posit.co/download/rstudio-desktop/ and, under section “2: Install RStudio”, click the big blue “Download RStudio Desktop” button.

Open the installer and follow the instructions.

Chromebooks

You cannot install RStudio on Chromebooks. You can use Posit Cloud (https://posit.cloud/) for free for up to 25 hours per month.


B. Updating R and RStudio

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.

B.1 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.3                         
<< 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.

2. Update 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

To update R, you need to remove any old R installations and then reinstall R.

First, go to Finder, click Applications, and drag and drop R to the bin. Then, follow the instructions from A.1 to reinstall it.

Chromebooks

You cannot install R on Chromebooks. You need to access a version of R installed on a remote machine or server.

You still may want to update packages, though. Check section C for that.

3. Update RStudio

Check if RStudio needs to be updated by clicking Help > Check for updates.

If an update is available, uninstall your current RStudio (not R, only RStudio). Next, follow the instructions in section A.2 of this document to install the most recent RStudio release.


C. Updating R packages

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

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