Foundations of
Data Science

Spring 2026 | Data 2 (399)
Jeffrey M. Girard | Lecture 02c

Roadmap

  1. Create self-contained data science reports using Quarto documents

  2. Include Markdown commands to format your Quarto documents

Quarto

Communicating with R

  • The Console is like a chat window with R
    • You send a command to R and get a response
    • Neither side of the conversation is saved
  • An R Script is like an email thread with R
    • You send many commands to R all at once
    • Only your side of the conversation is saved
  • A Quarto Document is like a scrapbook with R
    • You can combine code and formatted text
    • Both sides of the conversation are saved

Quarto

  • Quarto is a scientific/technical publishing system
  • Create dynamic content (e.g., code, output, and markdown) with R, Python, Julia, and Observable
  • Articles, reports, slideshows, websites, blogs, and books in HTML, PDF, MS Word, and ePub formats
  • Include equations, citations, crossrefs, figure panels, callouts, advanced layouts, etc.

Create an Quarto Document

  • Open the “File” menu in RStudio
  • Select the “New File” option
  • Select the “Quarto Document…” option
  • Keep the defaults (HTML) and hit “Create”
  • Open the “File” menu
  • Select the “Save” option
  • Note that it defaults to the project folder
  • Give it a name like “Lecture 02c” (or whatever)
  • Note that the file extension is .qmd

Render the boilerplate content

  • To see how it works, read the boilerplate content
  • Now click the “Render” button to create the output file
  • A preview of the output will appear in the Viewer tab
  • In the File tab, we see a new .html file was created
  • We can share this .html file with others
  • It includes all the formatted text, code, and R results

Remove the boilerplate content

  • The top part of the document is called the “Header”
  • You can change the title but keep it in quotes
  • Highlight and delete everything below the header
  • In the future, you can click “Create Empty Document”
  • Add embed-resources: true to the Header for assignments!

Add an R Chunk

  • Option 1: Click the green box with C and a plus sign icon (top-right)
  • Option 2: Ctrl+Alt+I (Win) or Cmd+Option+I (Mac)
  • Option 3: Type out ```{r} then new line and ``` yourself

Adding code to the chunk

  • Anything you put inside the “fences” (i.e., ```) will be treated as R code
  • The chunk operates like a mini console
  • Try doing some calculations in the chunk and hit the green arrow
  • The answer appears right below the chunk!
  • If we save and render the document, it appears in the output too
  • We can add options to the chunk but we will return to this later

Markdown

Markdown

  • Markdown is a simple text-to-HTML conversion language used by Quarto, GitHub, Obsidian, etc.
  • It will allow us to add formatted text, images, links, lists, etc. to our Quarto documents
  • Quarto will treat all text that is not in a code chunk as markdown

Formatting

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

Headings

Markdown Output
# Heading 1

Heading 1

## Heading 2

Heading 2

### Heading 3

Heading 3

#### Heading 4

Heading 4

Links and Images

Markdown Output
[https://quarto.org](https://quarto.org)
https://quarto.org
[Quarto](https://quarto.org)
Quarto
![Caption](https://placehold.co/100)

Caption

Unordered Lists

Markdown Output
* unordered list
  + sub-item 1
  + sub-item 2
    - sub-sub-item 1
  • unordered list
    • sub-item 1
    • sub-item 2
      • sub-sub-item 1

Ordered Lists

Markdown Output
1. ordered list
2. item 2
   i) sub-item 1
      A.  sub-sub-item 1
  1. ordered list
  2. item 2
    1. sub-item 1
      1. sub-sub-item 1