Install and Setup R
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
- Go to R’s official website at this link.
- Click
CRAN
under the Download section.
- 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.
- Click
download R for Windows
for installation files for Windows computers.
- Download and install (1)
base
and (2)Rtools
. It is recommended to use the default options during installation.- Note:
base
is the R program, andRtools
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.
- Note:
- Click this link to download and install the Quarto CLI plugin.
1.2 For Mac computers
- Go to R’s official website at this link.
- Click
CRAN
under the download section.
- 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.
- Click
download R for macOS
for the download file.
- 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”, whereX.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”, whereX.X.X
is the version number. - Refer to this link if you are unsure whether you have an Intel or Apple CPU.
- If you use an Intel-based CPU, download
- 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.
- Go to the RStudio website here.
- Scroll down to the download list and select the version that matches your computer (Mac/Windows).
- After downloading the installation file, follow the instructions to complete the installation. It is recommended to use the default settings.
- 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 pressEnter
. Check if you see the output2
.
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 clickCreate
.
- 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.
4 Recommended Setting for RStudio
After you have everything installed, it is highly recommended to set up RStudio based on my next tutorial here