🧭 Stage 1 · Quarto + RStudio Field Guide

~13 minutes Β· The map that unlocks the rest

Instructor Β· Stage 1 (~13 min). Have the .qmd source on the left and the rendered HTML on the right in RStudio. Narrate each section as you scroll through both. Students follow on screen β€” no R required to observe.

πŸ” Stage 1 Β· Decode the Map

Learn the building blocks of any .qmd file so you can read β€” and write β€” any Quarto document.

What is a .qmd file?

A Quarto Markdown file mixes three things in one document:

  1. YAML header β€” configuration at the very top (between --- dashes)
  2. Markdown prose β€” your narrative, headings, lists, images
  3. R code chunks β€” live code that runs and embeds output automatically

When you click Render (or run quarto render), Quarto executes the code, weaves output into prose, and produces polished HTML, PDF, or a slide deck β€” or all three from the same file.

Pirate coding gif


1 The YAML header

Think of it as the treasure map legend β€” it tells Quarto what to produce.

---
title: "My Report"
format:
  html:
    theme: cosmo
    toc: true
    code-fold: show
execute:
  echo: true
  warning: false
---
Key What it does
format: html Output as a web page (also pdf, docx, revealjs)
toc: true Auto table of contents
code-fold: show Show code with a collapse button
echo: false Hide code, keep output β€” great for client reports
theme: cosmo One word changes the whole visual design
Live experiment

Change cosmo to darkly or journal and re-render. The entire document reskins in seconds.


2 Markdown prose

Everything outside a code chunk is plain Markdown:

## A heading

Normal text. **Bold**, *italic*, `inline code`.

- Bullet one
- Bullet two

> A blockquote for emphasis

![Caption](https://example.com/image.png)

3 Inline R β€” numbers that never drift

One of Quarto’s most powerful features is embedding live R values directly in prose:

Code
treasure <- read.csv("data/treasure_hunt.csv")
n_teams  <- nrow(treasure)
top_score <- max(treasure$final_treasure)
top_major <- treasure$major[which.max(treasure$final_treasure)]

Write this sentence in your document:

β€œThe dataset contains 25 teams. The highest score was 99, achieved by a student in OMIS.”

When the data updates, the sentence updates. No copy–paste. No drift.

πŸ΄β€β˜ οΈ Fragment #1: The command that turns a raw .qmd into a finished document is render.


4 Code chunks

Code chunks are enclosed in triple backticks with {r}. Each chunk can have options set with #|:

Code
library(tidyverse)

treasure <- read_csv("data/treasure_hunt.csv", show_col_types = FALSE)

treasure |>
  summarise(
    n_teams      = n(),
    avg_score    = round(mean(final_treasure), 1),
    avg_clues    = round(mean(clues_solved), 1),
    fastest_min  = min(time_minutes)
  )
# A tibble: 1 Γ— 4
  n_teams avg_score avg_clues fastest_min
    <int>     <dbl>     <dbl>       <dbl>
1      25      80.7       6.8          40
Chunk option Effect
#| echo: false Hide code, show only output
#| eval: false Show code, do NOT run it
#| fig-width: 8 Control plot width
#| fig-cap: "..." Add a figure caption

5 Callouts β€” four types

Note

Note β€” contextual information worth knowing

Tip

Tip β€” best practices and suggestions

Warning

Warning β€” something the reader must watch out for

Important

Important β€” must-read information


6 Panel tabs β€” multiple views, one block

Use when you want analysis, evidence, and polished prose in one reproducible file.

Use when you want to present results without rebuilding everything in another app.

Use when you have multiple pages, navigation, or a project portfolio to share.


Stage 1 complete βœ…

You know the four building blocks of every Quarto document: YAML Β· Markdown Β· Inline R Β· Code chunks

Continue to πŸ“Š Stage 2: Analysis

Pirate coding gif