cyl mean
1 6 19.74286
2 4 26.66364
3 8 15.10000
R for Data Science
March 21, 2024
These slides are almost entirely copied from Tom Mock’s ‘Getting Started with Quarto’ workshop at rstudio::conf(2022).
Shared under Creative Commons 4.0 License.
Quarto® 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.
Quarto is the next generation of R Markdown. For everyone.
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
knitr
We learned from 10 years of literate programming with knitr
+ rmarkdown
Works with R, Python, Julia, Observable JS
knitr
and jupyter
engines
Works in RStudio, Jupyter Notebooks, VS Code
For this course, we’ll focus on R and RStudio
A Quarto document i.e. a
.qmd
is a plain text file, like a.rmd
, that can be rendered to many different formats
Quarto comes “batteries included” straight out of the box
revealjs
)See FAQs, including a conversion from RMarkdown formats to Quarto equivalents.
The 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 |
You can embed named hyperlinks, direct urls like https://quarto.org/, and links to other places in the document. The syntax is similar for embedding an inline image:
```{r}
#| output-location: column
#| label: fig-airquality
#| fig-cap: Temperature and ozone level.
#| fig-alt: A scatterplot of ozone level against temparature, with a local regression fit that has a confidence band. The ozone level is fairly constant at around 15ppb from a temperature of 55°F to 75°F, then increases linearly to around 80ppb at a temperature of 90°F, where the ozone level starts to asymptote. The points are generally close to this curve apart from 7 outliers with higher than expected ozone between 75°F and 95°F.
#| warning: false
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess")
```
Literate programming is writing out the program logic in a human language with included (separated by a primitive markup) code snippets and macros. - Wikipedia
Open a new, empty Quarto document in RStudio and copy the example code from the previous slide.
format
in the YAML to docx
rather than html
format: typst
create?“Yet Another Markup Language” or “YAML Ain’t Markup Language”
Then add option arguments!
format: html
```
r
) between curly braces {r}
#|
(hashpipe):
#| option1: value
Slidecraft 101 by Emil Hvitfeldt
Destination | Description |
---|---|
Quarto Pub | Publishing service for Quarto documents, websites, and books. |
GitHub Pages | Publish content based on source code managed within a GitHub repository. |
Posit Connect | Publishing platform for secure sharing of data products within an organization. |
Netlify | Professional web publishing platform. |
Confluence | Publishing platform for supporting team collaboration. |
… and more.
Visit https://quartopub.com/ and set up a free account.
quarto publish
At the Terminal, run:
See e.g. https://jjallaire.quarto.pub/
Visit https://app.netlify.com/ and set up a free account.
At the Terminal, run:
https://quarto.org: The official documentation
Awesome Quarto: A curated list of Quarto talks, tools, examples & articles
These slides are almost entirely copied from Tom Mock’s ‘Getting Started with Quarto’ workshop at rstudio::conf(2022).
Shared under Creative Commons 4.0 License.
Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0).