Chapter 28: Quarto

Published

April 21, 2024

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:

  1. 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*
  2. The rendered version of the qmd file

  3. Source/visual modes in RStudio

Keyboard shortcuts

Practice keyboard shortcuts such as:

  1. Cmd/Ctrl + Shift + Enter: RStudio executes the code and displays the results inline with the code
  2. Cmd/Ctrl + Shift + K: Render the document
  3. Cmd/Ctrl + / in visual mode: “Insert just about anything.”
  4. Cmd + Option + I / Ctrl + Alt + I: Insert a code chunk

Designing chunks

  1. Code chunks could be inline or displayed.

  2. Use #| for local chunk options.

  3. Use YAML for more global options. Refer to Section 28.5.3.

  4. Include chunk labels: #| label: some-good-label

    1. Caching computationally intensive tasks
    2. Graphics generated could have convenient labels used for cross-referencing in other parts of the document.
    3. Easier navigation
  5. Chunk labels have to be unique. Special label is called setup, so use it only when needed.

  6. 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

  1. Numbered list item 1

  2. Item 2. The numbers are incremented automatically in the output.

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:

Figure 1: Compare this figure with the default above.

Largest 20 diamonds

Table 1: The 20 Largest Diamonds: Cut, Color, Clarity, and Price
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