Skip to main content

Setting Up R, RStudio & Quarto

This guide walks through installing R, RStudio, Quarto, and the core R packages used across the course notes.

1. Installing R and RStudio

R is the statistical computing engine; RStudio is the integrated development environment (IDE) that bundles a script editor, console, plot viewer, and Quarto publishing tools.

Windows

  1. Download the latest R installer from CRAN and run the .exe file with default options.
  1. Download RStudio Desktop from Posit and run the installer.

macOS

  1. Download the macOS .pkg installer matching your processor (Apple Silicon or Intel) from CRAN.
  1. Download RStudio Desktop for macOS from Posit, open the .dmg, and drag RStudio to Applications.

2. Installing Course Packages

Install the full suite of packages used across all 32 notes once in the R console:

install.packages(c(
  "fpp3", "astsa", "tseries", "urca", "patchwork",
  "car", "slider", "janitor", "FinTS", "rugarch",
  "vars", "strucchange", "imputeTS"
))

3. Working with Quarto Documents (.qmd)

Quarto comes bundled with recent versions of RStudio (and can also be installed standalone from quarto.org). A .qmd file combines Markdown prose, LaTeX mathematics, and executable R chunks in one reproducible file.

Project Organization

  1. Create a dedicated folder on your machine (for example, applied-time-series/).
  2. In RStudio, choose File → New Project → Existing Directory and select that folder. Using an RStudio Project automatically sets the working directory so relative paths such as "data/google.csv" always work without calling setwd().
  3. Place downloaded course CSV/RDS files inside a data/ subfolder.

Essential Quarto Chunk Options

Quarto uses #| YAML comments inside code chunks:

```{r}
#| label: fig-series
#| fig-cap: "Monthly airline passengers (1949–1960)."
#| echo: true
library(fpp3)
as_tsibble(AirPassengers) |> autoplot(value)
```

Common options:

  • #| echo: false hides code while displaying output and plots.
  • #| include: false runs setup code silently without showing code or output.
  • #| eval: false displays code without executing it.
  • #| fig-cap: "..." attaches a numbered caption to a figure.

Optional: Display Plots in the Viewer Pane

If you prefer plots and tables to appear in RStudio’s Plots / Viewer pane rather than inline inside the editor:

  1. Open Tools → Global Options → R Markdown.
  2. Uncheck Show output inline for all R Markdown documents and click Apply.
Back to top