Introduction to Quarto

Colton Gearhart

2023-10-31

So what is Quarto?

Quarto® is an open-source scientific and technical publishing system built on Pandoc.

Quarto is the next-generation of RMarkdown, which is a platform that allows users to combine plain text and code in a single document and output to a variety of sources.

This means we can weave together narrative text and code to produce elegantly formatted output as documents, web pages, blog posts, books and more.

Quarto (and R Markdown) workflow

Why Quarto, instead of RMarkdown

  • Batteries included, shared syntax
  • Choose your own editor and your preferred data science language
  • Better accessibility and richer features out of the box
  • More enhancements overtime - RMarkdown still maintained, but majority of new features built into Quarto

Collaboration with other colleagues in other languages - shared format, choose your editor and your native language

  1. Reproducibility
  2. Re-usability
  3. Extensibility
  4. “Lazy” ability

Change your mental model

No more copy-paste, no more manually rebuilding analyses from disparate components, no more dread when the data is updated and you need to run an analysis.

Source

Output

Change your mental model

Source

Output

Change your mental model

---
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"
)
```

Where to use Quarto

We will be using RStudio. But this also works with Jupyter notebooks (python users), among other platforms.

So what is a Quarto doc?

A Quarto document i.e. a .qmd is a plain text file, like a .rmd, that can be rendered to many different formats

So what is a Quarto doc?

YAML

---
title: "ggplot2 demo"
author: "Norah Jones"
date: "5/22/2021"
format: 
  html:
    code-fold: true
    embed-resources: true
---

Currently our header is quite basic.
It includes:

  • The title of the document; title: “ggplot2 demo”

  • Who wrote it: author: “Norah Jones”

  • Date: “5/22/2021”

  • The output type: html_document

  • Option to display code; code-fold: true

  • Option to bundle all files into a single .html file; embed-resources: true

Code chunks

Code chunk options

Source: Code chunks

Code chunk example

```{r}
#| output-location: column
#| label: fig-airquality
#| fig-cap: Temperature and ozone level.
#| warning: false

library(ggplot2)

ggplot(airquality, aes(Temp, Ozone)) + 
  geom_point() + 
  geom_smooth(method = "loess"
)
```
Figure 1: Temperature and ozone level.

Markup text

Now that we have a report with a header and some code, we need to explain what the code is doing and why.

  • This is where the plain text comes in.

  • Outside of a code chunk, type anything you want. You can even include pictures and tables.

We can also Cross Reference.

Markup text

Text Formatting

Markdown Syntax Output
*italics* and **bold**
italics and bold
superscript^2^ / subscript~2~
superscript2 / subscript2
~~strikethrough~~
strikethrough
`verbatim code`
verbatim code

Source: Getting Started with Quarto

Headings

Markdown Syntax Output
# Header 1

Header 1

## Header 2

Header 2

### Header 3

Header 3

#### Header 4

Header 4

##### Header 5
Header 5
###### Header 6
Header 6

Source: Getting Started with Quarto

Inline code

Inside your text you can include executable code with the syntax:

For example:

There are 344 rows in the penguins data set.

Rendering file

Save your report and…

Rendering file

Look at your console while it renders: