Install and Setup R

Author
Affiliation

Wei Miao

UCL School of Management

Published

July 31, 2025

Uninstall Old R and RStudio

If you have used R or RStudio before, please uninstall both R and RStudio and follow the guide below to install the latest versions. Otherwise, Quarto may not work properly with older versions.

Make sure:

  • Your R version is 4.5.1. Note that the latest version of R is 4.5.1 as of August 2025, which we will use in this tutorial and throughout Term 1.
  • Your RStudio version is 2025.05.1+513 or higher.

If you switch to a new laptop later on, please return to this tutorial and reinstall R and RStudio following the same procedures.

1 Installation of R

1.1 For Windows computers

  1. Go to R’s official website at this link.
  2. Click CRAN under the Download section.

  1. You will see different mirrors for R download. These mirrors store the same installation files on different servers in various locations. Simply click any mirror.

  1. Click download R for Windows for installation files for Windows computers.

  1. Download and install (1) base and (2) Rtools. It is recommended to use the default options during installation.
    • Note: base is the R program, and Rtools is a developer tool to compile/install R packages.
    • It is highly recommended to change your system language to English before proceeding, or you may encounter unexpected bugs later.

  1. Click this link to download and install the Quarto CLI plugin.

1.2 For Mac computers

  1. Go to R’s official website at this link.
  2. Click CRAN under the download section.

  1. You will see different mirrors for R download. These mirrors store the same installation files on different servers in various locations. Simply click any mirror.

  1. Click download R for macOS for the download file.

  1. Download the correct .pkg file to install R:
    • If you use an Intel-based CPU, download R-4.X.X-x86_64.pkg under “For older Intel Macs”, where X.X.X is the version number.
    • If you use an Apple silicon chip such as M1, M1 Pro, etc., download R-4.X.X-arm64.pkg under “For Apple Silicon Macs”, where X.X.X is the version number.
    • Refer to this link if you are unsure whether you have an Intel or Apple CPU.

  1. Click this link to download and install the Quarto CLI plugin for macOS.

2 Install RStudio

RStudio is where we will write our R code. Please install RStudio by following the steps below.

  1. Go to the RStudio website here.
  2. Scroll down to the download list and select the version that matches your computer (Mac/Windows).
  3. After downloading the installation file, follow the instructions to complete the installation. It is recommended to use the default settings.
  4. After installation, you can find RStudio in the Applications folder on Mac or the Start menu on Windows.

3 Check success of installation

3.1 Check R and RStudio are properly installed

Please follow these steps to ensure you have successfully installed R and RStudio:

  • Step 1: Launch RStudio from your computer. Check if you see the following screen without any error messages.

  • Step 2: As shown in the picture, type 1+1 after the > prompt and press Enter. Check if you see the output 2.

If there are no error messages and you see the expected output, congratulations! You have successfully installed R and RStudio.

3.2 Check Quarto is properly installed

  • Step 1: Click the green plus sign (circled below) and select Quarto Document.

  • Step 2: Select Word and click Create.

  • Step 3: Click the Render button. You may be asked to save the .qmd file to a location. Save it to your Downloads folder. R will then render the .qmd document and generate a .docx file named “untitled.docx” in the same location.

  • Step 4: The .docx file should look like the example below. If you can generate the .docx file without issues, Quarto has successfully run on your computer!

Note: If you see a banner prompting that rmarkdown is not installed, click the Install button to install it. In the future, if you see a similar banner stating “Package XXX required but is not installed”, click the Install button to install the missing package, as it is needed for the current Quarto file to work properly.