04:00
Small Data SF
Posit, PBC
Posit, PBC
Data Science Educator
Developer Relations, Posit
Sara Altman
Sr. Product Marketing Manager
Developer Relations, Posit
Please share
04:00
These materials are pitched at someone who:
knows some Python + Markdown
has worked in VS Code
wants to learn about Quarto
We’ll teach you
What is Quarto
How to create documents with Quarto
How to create a dashboard from a notebook
My turn
Our turn
Your turn
During my turn and your turn segments – raise your hand
During our turn segments – also feel free to raise your hand for questions but if your question seems specific to your setup, we might come around and help during the next your turn break
Sit back and enjoy!
is an open technical content creation system.
you can weave together narrative and code to produce elegantly formatted output such as documents, web pages, blog posts, books, dashboards, and more, with…
Where does the name “Quarto” come from?
Quarto comes “batteries included” straight out of the box:
HTML reports and websites
PDF reports
MS Office (Word, Powerpoint)
Presentations (Powerpoint, Beamer, revealjs
)
Books
Dashboards
…
Feature | Quarto |
---|---|
Basic Formats | html, pdf, docx |
Beamer | beamer |
PowerPoint | pptx |
HTML Slides | revealjs |
Advanced Layout | Quarto Article Layout |
Cross References | Quarto Crossrefs |
Websites & Blogs | Quarto Websites, Quarto Blogs |
Books | Quarto Books |
Interactivity | Quarto Interactive Documents |
Journal Articles | Journal Articles |
Dashboards | Dashboards |
Quarto is a command line interface (CLI) that renders plain text formats (.qmd
, .rmd
, .md
) OR mixed formats (.ipynb
/Jupyter notebook) into static PDF/Word/HTML reports, books, websites, presentations and more.
Usage: quarto
Version: 1.5.57
Description:
Quarto CLI
Options:
-h, --help - Show this help.
-V, --version - Show the version number for this program.
Commands:
render [input] [args...] - Render files or projects to various document types.
preview [file] [args...] - Render and preview a document or website project.
serve [input] - Serve a Shiny interactive document.
create [type] [commands...] - Create a Quarto project or extension
create-project [dir] - Create a project for rendering multiple documents
convert <input> - Convert documents to alternate representations.
pandoc [args...] - Run the version of Pandoc embedded within Quarto.
typst [args...] - Run the version of Typst embedded within Quarto.
run [script] [args...] - Run a TypeScript, R, Python, or Lua script.
add <extension> - Add an extension to this folder or project
install [target...] - Installs an extension or global dependency.
publish [provider] [path] - Publish a document or project to a provider.
check [target] - Verify correct functioning of Quarto installation.
help [command] - Show this help or the help of a sub-command.
jupyter
evaluates Python code and returns a .md
file along with the evaluated code.md
file by Pandoc and converted to a final output formatwith a wider lens…
jupyter
or knitr
evaluates Python, Julia, R, or Observable code and returns a .md
file along with the evaluated code.md
file by Pandoc and converted to a final output formatYou can convert between .ipynb
and .qmd
representations of a notebook using the quarto convert
command.
For example:
in VS Code
quarto preview
in VS Code
quarto render
1. Software: Download and install Python and the latest version of Quarto:
2. Tools: Dowload and install VS Code and Jupyter and the Quarto extensions:
3. Exercises: Go to pos.it/smalldatasf-quarto-exercises
, click on Use this template then Create a new repository. Check Include all branches. Choose your personal GitHub repo as the Owner and give the repository a name.
4. Packages: Open VS Code. Under Start, click on Clone Git Repository, and paste the URL of your exercise repo.
Python: Create Environment...
and choose Venv
, then choose the (latest) Python version you have installed.requirements.txt
in the Select dependencies to install menu and hit OK.See full instructions under Setup: pos.it/smalldatasf-quarto-workshop
Then: In VS Code, open the olympicdash-0.ipynb
file.
Convert the file to .qmd
using quarto convert
.
Preview the .qmd
file.
Three components:
YAML: Metadata
Text: Markdown
Code: Executed via jupyter
or knitr
Weave it all together, and you have beautiful, powerful, and useful outputs!
Metadata: YAML
Text: Markdown
my-document.qmd
Text: Markdown
The `olympic.csv` dataset records [**Olympic**](https://en.wikipedia.org/wiki/Olympic_Games) athlete details.
The olympic.csv
dataset records Olympic athlete details.
Text: Markdown
Markdown syntax | Output |
---|---|
|
italics and bold |
|
superscript2 / subscript2 |
|
|
|
verbatim code |
Code
Code
{}
Inline code executes code within Markdown
Results in:
The number of medals is 5.
Code can include optional chunk options, in YAML style, identified by #|
at the beginning of the line
Code can include optional chunk options, in YAML style, identified by #|
at the beginning of the line
---
title: "Olympic Games"
format: html
---
This dataset records Olympic athlete details.
```{python}
#| include: false
#| fig.alt: "A scatterplot with country on the x-axis and medals on the y-axis."
from plotnine import ggplot, aes, geom_bar
(
ggplot(mpg, aes(x = "country", y = "medals"))
+ geom_bar()
)
```
Code can include optional chunk options, in YAML style, identified by #|
at the beginning of the line
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
In VS Code, open the olympicdash-0.qmd
file.
In the YAML, add an author
field and add your name.
Add some Markdown text to the document.
For one of the tables, add the chunk option echo: false
.
Add this to the top of the plotnine chart to set the order of medal
variable.
Save in between each step and see how the preview changes.
Markdown syntax | Output |
---|---|
|
https://quarto.org |
|
Quarto |
|
```{markdown}
| 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 |
You can add classes, attributes, and other identifiers to content using Divs and Spans.
Divs
::: {.border}
This content can be styled with a border
:::
Spans
[This is *some text*]{.class key="val"}
Callout blocks
my-document.qmd
Tip
Note that there are five types of callouts, including: note
, tip
, warning
, caution
, and important
.
Multiple columns
my-document.qmd
::: {layout-ncol=2}
![](penguin.jpg)
Photo by <a href="https://unsplash.com/@corneliusventures?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Cornelius Ventures</a> on <a href="https://unsplash.com/s/photos/penguin?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
:::
Photo by Cornelius Ventures on Unsplash
Tabsets
my-document.qmd
Change the html theme to sketchy
. (See https://quarto.org/docs/output-formats/html-themes.html for documentation on HTML theming.)
Edit the Markdown text you wrote in the previous exercise so that one of the words is blue.
Add a code chunk cell with the option include: false
. Use the dataset to find the most gold medals by team.
Use inline code to write a sentence such as: “The most gold medals won by a single team are [count].”
Add a Div of your choice.
A Quarto Project is a directory that contains a file called
_quarto.yml
.
This is a Quarto Project.
my-folder/
├── _quarto.yml
├── my-document.ipynb
This is not.
my-folder/
├── my-document.ipynb
A YAML file with particular keys and values that Quarto recognizes. Unrecognized keys are ignored.
A YAML file with particular keys and values that Quarto recognizes. Unrecognized keys are ignored.
_quarto.yml
project:
type: website
output-dir: docs
resources:
- images/python-logo.png
website:
page-navigation: true
title: "From Notebooks to Dashboards with Quarto"
description: "Small Data SF - From Notebooks to Dashboards with Quarto Workshop"
repo-url: https://github.com/posit-dev/small-data-sf-quarto-workshop
repo-actions: [edit, issue]
open-graph: true
sidebar:
background: "#FF6349"
logo: "images/logo.png"
pinned: true
align: center
tools:
- icon: github
href: https://github.com/posit-dev/small-data-sf-quarto-workshop
text: "GitHub"
- icon: code-square
href: https://posit.cloud
text: "Posit Cloud"
style: docked
search: true
collapse-level: 2
contents:
- href: index.qmd
text: Home
- href: setup.qmd
text: Setup
- section: "Modules"
contents:
- href: 0-intro-to-quarto/index.qmd
- href: 1-hello-dashboards/index.qmd
- href: 2-components-theming/index.qmd
- href: 3-deployment/index.qmd
page-footer:
right: "This page is built with 🩷 and [Quarto](https://quarto.org/)."
left: "© Copyright 2024"
background: "#FF6A8A"
format:
html:
theme:
light: [cosmo, style/light.scss]
dark: [cosmo, style/light.scss, style/dark.scss]
linkcolor: "#FF75EF"
toc: true
code-copy: true
code-overflow: wrap
mainfont: "Space Grotesk"
execute:
freeze: auto
echo: true
editor: source
Quarto projects have a _quarto.yml
file
The type
field in this file indicates the type of project:
default
: Collection of documents
website
: Websites (and blogs)
book
: Books
manuscript
: Manuscripts (Quarto 1.4+)
dashboard
: Dashboards (Quarto 1.4+)
thank you!
any questions?