Chapter 28: Quarto
Things to note from the chapter
Ways of seeing a Quarto file
This is an example file based on material for Chapter 28. Pay attention to two representations:
The text file with file extension
qmd
- Global control: An (optional) YAML header surrounded by
---
s - Code weaving: Chunks of R code surrounded by ```
- Formatting: Text mixed with simple text formatting like
# heading
and*italics*
- Global control: An (optional) YAML header surrounded by
The rendered version of the
qmd
fileSource/visual modes in RStudio
Keyboard shortcuts
Practice keyboard shortcuts such as:
- Cmd/Ctrl + Shift + Enter: RStudio executes the code and displays the results inline with the code
- Cmd/Ctrl + Shift + K: Render the document
- Cmd/Ctrl + / in visual mode: “Insert just about anything.”
- Cmd + Option + I / Ctrl + Alt + I: Insert a code chunk
Designing chunks
Code chunks could be inline or displayed.
Use
#|
for local chunk options.Use YAML for more global options. Refer to Section 28.5.3.
Include chunk labels:
#| label: some-good-label
- Caching computationally intensive tasks
- Graphics generated could have convenient labels used for cross-referencing in other parts of the document.
- Easier navigation
Chunk labels have to be unique. Special label is called
setup
, so use it only when needed.Use “layering” chunk options to tailor to audience. Refer to Section 28.5.2.
Recreate Figure 28.5
Text formatting
italic bold underlined strikeout in small caps code
superscript2 subscript2
Headings
1st Level Header
2nd Level Header
3rd Level Header
Lists
Bulleted list item 1
Item 2
Item 2a
Item 2b
Numbered list item 1
Item 2. The numbers are incremented automatically in the output.
Links and images
Tables
First Header | Second Header |
---|---|
Content Cell | Content Cell |
Content Cell | Content Cell |
Diamond sizes
We have data about 53,940 diamonds. Only 126 are larger than 2.5 carats. The distribution of the remainder is shown below:
Largest 20 diamonds
carat | cut | color | clarity | price |
---|---|---|---|---|
5.01 | Fair | J | I1 | 18018 |
4.50 | Fair | J | I1 | 18531 |
4.01 | Premium | I | I1 | 15223 |
4.01 | Premium | J | I1 | 15223 |
4.00 | Very Good | I | I1 | 15984 |
4.13 | Fair | H | I1 | 17329 |
3.67 | Premium | I | I1 | 16193 |
3.51 | Premium | J | VS2 | 18701 |
3.50 | Ideal | H | I1 | 12587 |
3.01 | Fair | H | I1 | 10761 |
3.65 | Fair | H | I1 | 11668 |
3.04 | Premium | I | SI2 | 18559 |
3.22 | Ideal | I | I1 | 12545 |
3.24 | Premium | H | I1 | 12300 |
3.01 | Premium | G | SI2 | 14220 |
3.01 | Good | H | SI2 | 18593 |
3.00 | Premium | G | I1 | 13203 |
3.40 | Fair | D | I1 | 15964 |
3.01 | Premium | J | SI2 | 18710 |
3.00 | Good | I | I1 | 10863 |