.qmd’sArtwork by @allison_horst
.qmd file = code + textA .qmd file holds two things together:
When you render the file, Quarto combines them into a polished output: .html, .pdf, .docx, and more.
.qmdEvery .qmd file is made up of exactly three things:
We’ll look at each one in detail — but first, let’s see them all together in a real example.
.qmd fileHere’s what a full .qmd file looks like — we’ll break down each piece next.
---
title: "Hello, Penguins"
format: html
execute:
echo: false
---
## Meet the penguins
The `penguins` data contains size measurements for
penguins from three islands in the Palmer Archipelago,
Antarctica.
```{r}
#| label: fig-penguins
#| warning: false
pacman::p_load(tidyverse, palmerpenguins)
penguins |>
ggplot(aes(x = flipper_length_mm, y = bill_length_mm)) +
geom_point(aes(color = species)) +
theme_minimal()
```The YAML block sits at the very top of the file, between --- lines
It controls settings like title, author, and output format
More YAML options on Quarto website
What you’ll see in your practice assignments
Outside of code chunks, you write plain text using Markdown formatting:
Tip: Use the Visual Editor (top of the editor window) for a Word-like experience if you prefer not to write raw Markdown yet.
Code chunks are where your R code lives
```{r} to start and ``` to closeYou can control how a chunk behaves with #| options at the top of the chunk:
| Option | What it does |
|---|---|
echo: false |
Hides the code in output (results still show) |
warning: false |
Hides warnings from the output |
include: false |
Hides both code and results (still runs) |
eval: false |
Don’t run the code (no output) |
qmd file has code that doesn’t work or takes a long time to run, but you still want to render the document
.qmd file: overviewFour steps:
.html outputTwo options:
File → New File → Quarto Document... → OKIn the pop-up window:
HTMLKnitrUse visual markdown editorCreate
Create, a template .qmd opens in your editor--- that ends the YAML
File → SaveWhen saving, specify:
.qmd as the extensionlesson#_quarto_work.qmdRendering turns your .qmd into a viewable .html file.
Two options:
After rendering:
.qmd and .html files appear in your folder — the HTML takes its name from the .qmd.qmd vs. .html output.html — they can view results without running any code themselves.qmd file
.html output
Where does the HTML preview open?
Preview in Window — opens in a browser tabPreview in Viewer Pane — opens in the bottom-right RStudio paneWhere does code output appear?
Chunk Output Inline — output appears below the chunk in the editorChunk Output in Console — output appears in the Console pane
.qmd files, which combine text and code into a single document
.qmd file:
.qmd file to produce an HTML outputQuarto and .qmd’s