Install and Setup R

Author
Affiliation

Wei Miao

UCL School of Management

Published

July 29, 2026

ImportantUninstall 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.6.1 or higher. Note that the latest version of R is 4.6.1 as of July 2026, which we will use in this tutorial and throughout Term 1.
  • Your RStudio version is 2026.07.1+147 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. On the Rtools page, choose the version that matches your R release; the page states which R versions each Rtools release supports.
    • 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, a standalone command-line publishing tool.

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, where X.X.X is the version number (4.6.1 at the time of writing):
    • If you use an Apple silicon chip such as M1, M4, etc., download R-X.X.X-arm64.pkg under “For Apple silicon (M1,2,..) Macs”. This build requires macOS 14 (Sonoma) or higher.
    • If you use an Intel-based CPU, download R-X.X.X-x86_64.pkg under “For older Intel Macs”. This build requires macOS 11 (Big Sur) or higher.
    • Refer to this link if you are unsure whether you have an Intel or Apple silicon chip.

  1. Click this link to download and install the Quarto CLI 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 Posit’s download page here. RStudio is now developed by Posit, so the page is hosted on Posit’s website.
  2. Under RStudio Desktop, click Download in the free Open Source Edition column, not Buy now under RStudio Desktop Pro. This takes you to the Direct Downloads (Open Source) table for the RStudio IDE, where you should take the .dmg file for Mac or the .exe file for Windows. Ignore the Direct Downloads (Commercial) table further down the page, which is for RStudio Desktop Pro.
  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 (highlighted 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. RStudio 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.