You are sneaky!
Hello Quarto
You know R
You know a little bit of Markdown
You want to learn about Quarto, the next-generation of RMarkdown
Quarto syntax and formats
More Markdown
Even more R along the way!
v2022.07.1
or later?pkg_list <- c(
"tidyverse", "gt", "gtExtras", "reactable", "ggiraph", "here", "quarto",
"rmarkdown", "gtsummary", "palmerpenguins", "fs", "skimr"
)
install.packages(pkg_list)
Great, let’s get started!
https://github.com/jthomasmock/quarto-workshop.git
locallyQuarto® is an open-source scientific and technical publishing system built on Pandoc
You can weave together narrative text and code to produce elegantly formatted output as documents, web pages, blog posts, books and more.
knitr
started in 2011, RMarkdown in 2014knitr
We learned from 10 years of literate programming with knitr
+ rmarkdown
knitr
knitr
knitr
to execute code and generate a temporary output .md
The .md
file is processed via Pandoc and Quarto’s Lua filters + Bootstrap CSS for HTML or LaTeX for PDF and converted to a final output format
Lua filters written by R/Python/Julia developers should be interchangeable between formats - typically not language specific!
htmlwidgets
in R and Jupyter widgets for Python/JuliaQuarto includes native support for Observable JS, a set of enhancements to vanilla JavaScript created by Mike Bostock (also the author of D3). Observable JS is distinguished by its reactive runtime, which is especially well suited for interactive data exploration and analysis.
Converting temperature from ℃ to ℉
Celsius = ℃ and Fahrenheit = ℉.
viewof bill_length_min = Inputs.range(
[32, 50],
{value: 35, step: 1, label: "Bill length (min):"}
)
viewof islands = Inputs.checkbox(
["Torgersen", "Biscoe", "Dream"],
{ value: ["Torgersen", "Biscoe"],
label: "Islands:"
}
)
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
thomasmock$ quarto --help
Usage: quarto
Version: 1.0.36
Description:
Quarto CLI
Options:
-h, --help - Show this help.
-V, --version - Show the version number for this program.
Commands:
render [input] [args...] - Render input file(s) to various document types.
preview [file] [args...] - Render and preview a document or website project.
serve [input] - Serve a Shiny interactive document.
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.
run [script] [args...] - Run a TypeScript, R, Python, or Lua script.
install <type> [target] - Installs an extension or global dependency.
publish [provider] [path] - Publish a document or project. Available providers include:
check [target] - Verify correct functioning of Quarto installation.
help [command] - Show this help or the help of a sub-command.
materials/workshop/03-authoring/visual-editor.qmd
quarto preview notebook.ipynb --to html
Treat YAML as a “raw cell” in Jupyter - Jupyter doesn’t care about YAML, but it’s needed/used by Quarto
Feature | R Markdown | Quarto |
---|---|---|
Basic Formats | ||
Beamer | ||
PowerPoint | ||
HTML Slides | ||
Advanced Layout |
Feature | R Markdown | Quarto |
---|---|---|
Cross References | ||
Websites & Blogs | ||
Books | ||
Interactivity | Shiny Documents | Quarto Interactive Documents |
Paged HTML | pagedown | Summer 2022 |
Journal Articles | rticles | Summer 2022 |
Dashboards | flexdashboard | Fall 2022 |
.Rmd
or .ipynb
?For some of you - nothing changes! Keep using RMarkdown and Jupyter.
However, most existing .rmd
or .ipynb
can be rendered as-is via Quarto
Collaboration with other colleagues in other languages - shared format, choose your editor and your native language
quarto render
Source
Output
---
title: "ggplot2 demo"
author: "Norah Jones"
date: "5/22/2021"
format:
html:
fig-width: 8
fig-height: 4
code-fold: true
---
## Air Quality
@fig-airquality further explores the impact of temperature
on ozone level.
```{r}
#| label: fig-airquality
#| fig-cap: Temperature and ozone level.
#| warning: false
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess"
)
```
.qmd
is a plain text fileThe YAML metadata or header is:
processed in many stages of the rendering process and can influence the final document in many different ways. It is placed at the very beginning of the document and is read by each of Pandoc, Quarto and
knitr
. Along the way, the information that it contains can affect the code, content, and the rendering process.
Quarto is based on Pandoc and uses its variation of markdown as its underlying document syntax. Pandoc markdown is an extended and slightly revised version of John Gruber’s Markdown syntax.
Markdown is a plain text format that is designed to be easy to write, and, even more importantly, easy to read
Markdown Syntax | Output |
---|---|
|
italics and bold |
|
superscript2 / subscript2 |
|
|
|
verbatim code |
Markdown Syntax | Output |
---|---|
|
Header 1 |
|
Header 2 |
|
Header 3 |
|
Header 4 |
|
Header 5 |
|
Header 6 |
```{python}
#| eval: false
#| label: fig-polar
#| fig-cap: "A line plot on a polar axis"
import numpy as np
import matplotlib.pyplot as plt
r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(
subplot_kw = {'projection': 'polar'}
)
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```
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
thomasmock$ quarto --help
Usage: quarto
Version: 1.0.36
Description:
Quarto CLI
Options:
-h, --help - Show this help.
-V, --version - Show the version number for this program.
Commands:
render [input] [args...] - Render input file(s) to various document types.
preview [file] [args...] - Render and preview a document or website project.
serve [input] - Serve a Shiny interactive document.
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.
run [script] [args...] - Run a TypeScript, R, Python, or Lua script.
install <type> [target] - Installs an extension or global dependency.
publish [provider] [path] - Publish a document or project. Available providers include:
check [target] - Verify correct functioning of Quarto installation.
help [command] - Show this help or the help of a sub-command.
Because Quarto is a command line interface (CLI), there are times you’ll need to use it via the terminal. A great overview of using the command line and navigating files/directories is available via the Data Carpentries or a great interactive tool for understanding commands: https://tldr.ostera.io
Command | Action |
---|---|
pwd |
Print name of current working directory |
cd |
Change current working directory |
ls |
List directory contents |
quarto --help |
Return quarto help docs |
mkdir howdy |
Make a new folder/directory called “howdy” |
rm folder-name/some-file.qmd |
Delete some-file.qmd in the folder-name directory |
materials/workshop/01-intro/history.qmd
Render ->
buttonMove to the integrated terminal and execute:
Render via terminal with quarto render history.qmd --to pdf
Compare to the HTML version