flowchart LR
A[1] --> B(2)
B --> C{3}
C --> D[4]
C --> E[5]
Anatomy of a Quarto document
Authoring Quarto
Changing formats
Presentations with reveal.js
PDFs with Typst
Dashboards
.qmd file format with three components:
YAML: Metadata
Text: Markdown
Code: R, Python, Observable, and Julia
Weave it all together, and you have beautiful, powerful, and useful outputs!
Metadata: YAML
Metadata: YAML
Text: Markdown
report.qmd
Text: Markdown
| Markdown syntax | Output |
|---|---|
|
italics and bold |
|
superscript2 / subscript2 |
|
|
|
verbatim code |
Text: Markdown
Drug X achieved **superior** response and `survival outcomes`
Results in:
Drug X achieved superior response and survival outcomes
Code
report.qmd
---
title: "Phase III Trial Summary for Novel Oncology Agent (Drug X)"
format: html
---
Drug X achieved superior response and survival outcomes
with a statistically significant p-value for Overall
Survival (p = 0.003) and a favorable Hazard Ratio (0.65).
```{r}
gt(
demographics,
caption = "Baseline Demographics (Intent-to-Treat Population)"
)
```Code
report.qmd
---
title: "Phase III Trial Summary for Novel Oncology Agent (Drug X)"
format: html
---
Drug X achieved superior response and survival outcomes
with a statistically significant p-value for Overall
Survival (p = 0.003) and a favorable Hazard Ratio (0.65).
```{r}
gt(
demographics,
caption = "Baseline Demographics (Intent-to-Treat Population)"
)
```{}Code can include optional chunk options, in YAML style, identified by #| at the beginning of the line
---
title: "Phase III Trial Summary for Novel Oncology Agent (Drug X)"
format: html
---
Drug X achieved superior response and survival outcomes
with a statistically significant p-value for Overall
Survival (p = 0.003) and a favorable Hazard Ratio (0.65).
```{r}
#| echo: false
gt(
demographics,
caption = "Baseline Demographics (Intent-to-Treat Population)"
)
```| Option | Description |
|---|---|
eval |
Evaluate the code chunk |
echo |
Include the source code |
warning |
Include warnings |
include |
Include code and results |
Other options: https://quarto.org/docs/computations/execution-options.html
Inline code executes code within Markdown
report.qmd
Results in:
Drug X achieved superior response and survival outcomes with a statistically significant p-value for Overall Survival (p = 0.003).
01-exercise.qmd and run the code chunks (in order).#| include: false chunk option to the first cell. Preview the file and note the differences.author field and add your name. Preview the file.code-fold to be true. Preview the file.** and (2) use inline code instead of hardcoded values for the p-value:05:30
Anatomy of a Quarto document
Authoring Quarto
Changing formats
Presentations with reveal.js
PDFs with Typst
Dashboards
| Markdown syntax | Output |
|---|---|
|
https://quarto.org |
|
Quarto |
|
| Right | Left | Default | Center |
|---|---|---|---|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
| Right | Left | Default | Center |
|---|---|---|---|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
\[E = mc^{2}\]
Divs
::: {.border}
This content can be styled with a border
:::
Spans
[This is *some text*]{.class key="val"}
This is some text
Callout blocks
report.qmd
Tip
Note that there are five types of callouts, including: note, tip, warning, caution, and important.
Multiple columns
report.qmd
::: {layout-ncol=2}

Photo by <a href="https://unsplash.com/@_louisreed?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Louis Reed</a> on <a href="https://unsplash.com/photos/refill-of-liquid-on-tubes-pwcKF7L4-no?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
:::
Photo by Louis Reed on Unsplash
Tabsets
report.qmd
This is text that is red.
Anatomy of a Quarto document
Authoring Quarto
Changing formats
Presentations with reveal.js
PDFs with Typst
Dashboards
report.qmd
Anatomy of a Quarto document
Authoring Quarto
Changing formats
Presentations with reveal.js
PDFs with Typst
Dashboards
reveal.js presentations allow you to create stunning presentations on the web.
…and much more
The quarto-revealjs-editable extension allows for the repositioning and resizing of images and text divs directly in previewed slides.
Learn more: quarto-revealjs-editable
Anatomy of a Quarto document
Authoring Quarto
Changing formats
Presentations with reveal.js
PDFs with Typst
Dashboards


Learn more: Typst in Quarto
Control the size of the page (papersize), the page margins (margin), and the number of columns used for page content (columns):
Learn more: Page Layout
Add a .block class to change appearance of blocks:
Learn more: Typst Blocks
Learn more: Custom Typst Formats
important callout box to “Key Findings at a Glance”:format to revealjs. Preview the document.format to typst. Preview the document.Note
Removing code-fold, code-summary, and embed-resources is not required because these are html only features. However, I’d recommend removing them to keep your document tidy.
Anatomy of a Quarto document
Authoring Quarto
Changing formats
Presentations with reveal.js
PDFs with Typst
Dashboards
Dashboards are composed of cards.
Cards are arranged into rows and columns.
Pages, tabsets, and sidebars allow for more advanced layouts.
Begin with front matter:
Add a card:
Add a card:
Continue adding cards:
Add a title to your cards:

## Rows {auto-animate=true}
By default, cards are laid out in rows:
By default, cards are laid out in rows:
We can change it to be columns instead:
Alternatively, we can use headings to arrange cards:
Alternatively, we can use headings to arrange cards:
Make another row with content:
Continue adding content:
We can add columns within our rows:
Or use tabsets to put content in different tabs:
Use a Level 1 heading to create new pages:
Use a Level 1 heading to create new pages:
Add a logo and buttons to your navigation bar:
dashboard.qmd
---
title: "My first Quarto dashboard"
format:
dashboard:
logo: images/car.png
nav-buttons:
- reddit
- icon: gitlab
href: https://gitlab.com/ivelasq
---
## Row
Here is my dashboard:
# Page 1
```{r}
#| title: "Plot 1"
plot(mtcars)
```
```{r}
#| title: "Plot 2"
plot(mtcars$mpg)
```
# Page 2
```{r}
#| title: "Plot 3"
plot(mtcars$hp)
```Add a logo and buttons to your navigation bar:
dashboard.qmd
---
title: "My first Quarto dashboard"
format:
dashboard:
logo: images/car.png
nav-buttons:
- reddit
- icon: gitlab
href: https://gitlab.com/
---
## Row
Here is my dashboard:
# Page 1
```{r}
#| title: "Plot 1"
plot(mtcars)
```
```{r}
#| title: "Plot 2"
plot(mtcars$mpg)
```
# Page 2
```{r}
#| title: "Plot 3"
plot(mtcars$hp)
```
See more options: https://quarto.org/docs/reference/projects/websites.html#navbar
Cards are the fundamental unit of display within dashboards.
Cards can also have arbitrary markdown:
Enclose the both the cell and the content in a .card div to include content alongside the output of a cell:
Content that is included at the top of a dashboard is considered leading content, and will be included as is with no card styling:
Both interactive JavaScript-based plots and standard raster based plots are supported.
Size plots in static dashboards using code chunk options:
Produce tabular output within cards:
Produce tabular output within cards:
Value boxes display simple values within a dashboard:
dashboard.qmd
---
title: "My first Quarto dashboard"
format: dashboard
---
## Row
::: {.valuebox color="#F52A32"}
Last updated:
`{{r}} Sys.Date()`
:::
```{r}
#| content: valuebox
#| title: "Spam per day"
n <- mtcars |> tibble::as_tibble() |> dplyr::count() |> dplyr::pull(n)
list(
icon = "trash",
color = "#F52A32",
value = n
)
```
## Row
```{r}
#| title: "Plot 2"
plot(mtcars$mpg)
```dashboard.qmd
---
title: "My first Quarto dashboard"
format: dashboard
---
## Row
::: {.valuebox color="#F52A32"}
Last updated:
`{r} Sys.Date()`
:::
```{r}
#| content: valuebox
#| title: "Spam per day"
n <- mtcars |> tibble::as_tibble() |> dplyr::count() |> dplyr::pull(n)
list(
icon = "trash",
color = "#F52A32",
value = n
)
```
## Row
```{r}
#| title: "Plot 2"
plot(mtcars$mpg)
```
There are several ways to layout inputs within interactive dashboards:
Sidebars provide a collapsible vertical panel for inputs.
Toolbars provide a horizontal panel for inputs.
Card Inputs provide a panel for card-specific inputs.
There are several ways to layout inputs within interactive dashboards:
Sidebars provide a collapsible vertical panel for inputs.
Toolbars provide a horizontal panel for inputs.
Card Inputs provide a panel for card-specific inputs.
To include a sidebar, add the .sidebar class to a Level 2 heading:
dashboard.qmd
---
title: "My first Quarto dashboard"
format: dashboard
---
## {.sidebar}
Sidebar text here!
## Column
### Row
::: {.valuebox color="#F52A32"}
Last updated:
`{{r}} Sys.Date()`
:::
```{r}
#| content: valuebox
#| title: "Spam per day"
n <- mtcars |> tibble::as_tibble() |> dplyr::count() |> dplyr::pull(n)
list(
icon = "trash",
color = "#F52A32",
value = n
)
```
### Row
```{r}
#| title: "Plot 2"
plot(mtcars$mpg)
```To include a sidebar, add the .sidebar class to a Level 2 heading:
dashboard.qmd
---
title: "My first Quarto dashboard"
format: dashboard
---
## {.sidebar}
Sidebar text here!
## Column
### Row
::: {.valuebox color="#F52A32"}
Last updated:
`` `{r} Sys.Date()` ``
:::
```{r}
#| content: valuebox
#| title: "Spam per day"
n <- mtcars |> tibble::as_tibble() |> dplyr::count() |> dplyr::pull(n)
list(
icon = "trash",
color = "#F52A32",
value = n
)
```
### Row
```{r}
#| title: "Plot 2"
plot(mtcars$mpg)
```
dashboard.qmd
---
title: "My first Quarto dashboard"
format:
dashboard:
orientation: rows
server: shiny
---
```{r}
#| context: setup
library(ggplot2)
```
## {.sidebar}
```{r}
selectInput(
"variableChoice",
"Choose a variable:",
choices = names(mtcars)
)
```
## Column
### Row
Here is my dashboard:
### Row
```{r}
#| title: "Plot 2"
plotOutput("variablePlot")
```
```{r}
#| context: server
output$variablePlot <- renderPlot({
yVar <- mtcars[[input$variableChoice]]
plot(mtcars$index, yVar)
})
```dashboard.qmd
---
title: "My first Quarto dashboard"
format:
dashboard:
orientation: rows
server: shiny
---
```{r}
#| context: setup
library(ggplot2)
```
## {.sidebar}
```{r}
selectInput(
"variableChoice",
"Choose a variable:",
choices = names(mtcars)
)
```
## Column
### Row
Here is my dashboard:
### Row
```{r}
#| title: "Plot 2"
plotOutput("variablePlot")
```
```{r}
#| context: server
output$variablePlot <- renderPlot({
yVar <- mtcars[[input$variableChoice]]
plot(mtcars$index, yVar)
})
```
01-dashboard.qmd and render the dashboard.orientation to rows to see how the layout changes.{.tabset} to ## Columns.setup chunk called Data, and another after all of the code chunks called About. Write some text under About and rerender to see multiple pages.05:30