Metadata: YAML
Text: Markdown
Code: knitr
or jupyter
Add it all together, and you have beautiful, powerful, and useful outputs!
Literate programming is writing out the program logic in a human language with included (separated by a primitive markup) code snippets and macros. - Wikipedia
---
title: "ggplot2 demo"
date: "5/22/2021"
format: html
---
## Air Quality
There is a relationship between temperature and the ozone level.
```{r}
#| label: fig-airquality
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess"
)
```
“Yet Another Markup Language” or “YAML Ain’t Markup Language”
format: html
To avoid manually typing out all the options, every time!
Executing the Quarto Render button in RStudio will call Quarto render in a background job - this will prevent Quarto rendering from cluttering up the R console, and gives you and easy way to stop.
quarto render
materials/workshop/visual-editor.qmd
quarto render
, and in R console via quarto::quarto_render()
Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs. - Lint
RStudio + VSCode provide rich tab-completion - start a word and tab to complete, or Ctrl + space
to see all available options.
Ctrl + space
to see the available YAML optionsquarto.org/docs/reference/formats/html
You can use the HTML reference if needed.
Markdown Syntax | Output |
---|---|
|
|
|
|
|
|
|
continues after
|
|
|
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](https://quarto.org/),
direct urls like <https://quarto.org/>, and links to
[other places](#quarto-anatomy) in
the document. The syntax is similar for embedding an
inline image: ![Boston terrier](images/howard-gentleman.jpeg){fig-alt="A boston terrier's dressed up like a victorian gentleman"}.
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:
| 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 |
knitr
itself can turn R dataframes into tables with knitr::kable()
A very simple table generator, and it is simple by design. It is not intended to replace any other R packages for making tables. . . .
mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb | |
---|---|---|---|---|---|---|---|---|---|---|---|
Mazda RX4 | 21.0 | 6 | 160 | 110 | 3.90 | 2.620 | 16.46 | 0 | 1 | 4 | 4 |
Mazda RX4 Wag | 21.0 | 6 | 160 | 110 | 3.90 | 2.875 | 17.02 | 0 | 1 | 4 | 4 |
Datsun 710 | 22.8 | 4 | 108 | 93 | 3.85 | 2.320 | 18.61 | 1 | 1 | 4 | 1 |
Hornet 4 Drive | 21.4 | 6 | 258 | 110 | 3.08 | 3.215 | 19.44 | 1 | 0 | 3 | 1 |
Hornet Sportabout | 18.7 | 8 | 360 | 175 | 3.15 | 3.440 | 17.02 | 0 | 0 | 3 | 2 |
Valiant | 18.1 | 6 | 225 | 105 | 2.76 | 3.460 | 20.22 | 1 | 0 | 3 | 1 |
Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do. - Donald Knuth, Literate Programming 1
I like dogs
And I like cats
Pandoc and therefore Quarto can parse “fenced Div
blocks”
::: {.border}
This content can be styled with a border
:::
This content can be styled with a border
This is text with [special]{style="color:red;"} formatting.
This is text with special formatting.
You’re not limited to HTML/CSS concepts - Pandoc and Quarto also have “attributes” that can be assigned in this way.
:::
div as a HTML <div>
but it can also apply in specific situations to content in PDF[text]{.class}
spans can be thought of a <span .class>Text</span>
but again are a bit more transferable if using Pandoc/Quarto native attributes.The following, if specifying a Quarto class can often apply between formats.
:::{.callout-note}
Note that there are five types of callouts, including:
`note`, `tip`, `warning`, `caution`, and `important`.
:::
:::{.callout-note}
Note that there are five types of callouts, including:
`note`, `warning`, `important`, `tip`, and `caution`.
:::
:::{.callout-tip}
## Tip With Caption
This is an example of a callout with a caption.
:::
:::{.callout-caution collapse="true"}
## Expand To Learn About Collapse
This is an example of a 'folded' caution callout that can be expanded by the user. You can use `collapse="true"` to collapse it by default or `collapse="false"` to make a collapsible callout that is expanded by default.
:::
materials/workshop/02-authoring/callout-boxes.qmd
materials/workshop/02-authoring/callout-pdf.qmd
and render it as wellBasic markdown syntax:
![Boston Terrier](images/boston-terrier.png)
![Boston terrier](images/boston-terrier.png){fig-align="left"}
![](images/boston-terrier.png){fig-align="right" fig-alt="A photo a Boston Terrier."}
::: {#fig-bostons layout-ncol=2}
![Excited](images/boston-terrier.png){#fig-boston width="250px"}
![Sleeping](images/boston-sleep.png){#fig-sleep width="250px"}
Two states of Howard
:::
::: {#fig-bostons layout-nrow=2}
![Excited](images/boston-terrier.png){#fig-boston width="250px"}
![Sleeping](images/boston-sleep.png){#fig-sleep width="250px"}
![Still Excited](images/boston-terrier.png){#fig-boston width="250px"}
![Still sleeping](images/boston-sleep.png){#fig-sleep width="250px"}
:::
Two states of Howard, twice
::: {layout-ncol="2"}
![Excited](images/boston-terrier.png){width="250px"}
![Sleeping](images/boston-sleep.png){width="250px"}
![Still Excited](images/boston-terrier.png){width="250px"}
![Still sleeping](images/boston-sleep.png){width="250px"}
Two states of Howard, twice
:::
Two states of Howard, twice
mermaid
flowchart LR A[Hard edge] --> B(Round edge) B --> C{Decision} C --> D[Result one] C --> E[Result two]