SAVOR: Part II

Dynamic & Reproducible reporting with Quarto

Boris Hejblum

June 10, 2025

Literate programming

80’s idea from D. Knuth:

write code for humans, not for computer

Dynamic reporting

One document to rule them all with both text & code
⇒ export to different formats:

source: Posit Quarto cheatsheet

Reproducible research

Science reproducibility crisis

  • Is most scientific research false ? Ioanidis et al.

  • have you had to redo a whole analysis with just slightly different data
    (e.g. 1 patient added or removed ?)

French book on reproducible research:

Vers une recherche reproductible : faire évoluer ses pratiques, Desquilbet et al.

In : .qmd (“Quarto markdown”)

  • markdown: lightweight structured text

  • qmd = (or Python, Julia, …) + markdown

  • Quarto + pandoc
    ⇒ output in many formats (.docx, .pdf, .html, etc…)

source: Quarto cheatsheet

Note

these materials have been prepared in Quarto

.qmd structure

  1. YAML Header:
---  
title: "SAVOR: Part II"
subtitle: "Dynamic & Reproducible reporting with Quarto"
author: "Boris Hejblum"
date: 06/10/2025
format: revealjs
---
  1. Document body
    • Text blocks:
      Narration
    • Code chunks:
    ```{r}
    #| option_name: value
    (several) code lines...
    ```

Code chunks

Basic chunk options

  • results (default: 'markup')

    • 'asis' – passthrough results
    • 'hide' – do not display results
    • 'hold' – put all results below all code
  • eval – Run code in chunk (default: true)

  • echo – Display code in output document (default: true)

  • message – display code messages in document (default: true)

  • error – Display error messages in output document (true) or stop render when errors occur (default: false)

Code display options

  • tidy – tidy code for display (default: false)
  • warning – display code warnings in document (default: true)
  • collapse – collapse all output into single block (default: false)
  • highlight – highlight source code (default: true)
  • include – include chunk in doc after running (default: true)
  • comment – prefix for each line of results (default: ##)

Plots & figures

  • fig-align – figure postion: 'left' (default), 'right', or 'center'
  • fig-cap – figure caption as character string (default is NULL)
  • fig-cap-location – caption position: 'top' (default), 'bottom' or 'margin'
  • fig-height, fig-width – Dimensions of plots in inches

cache

Long running code chunks

  • cache – cache results for future knits (default: false)
  • dependson – optional chunk dependencies for caching

Additional features

Multiple files

  • child – list offile(s) to knit and then include (default is NULL)

not just R (python, Julia, SAS …)

  • engine – code language used in chunk (default in RStudio )

Text

Markdown syntax

  • *italic*italic
  • **bold**bold
  • ~~no~~strikethrough
  • `code` — verbatim code
  • ^2^ — superscript2
  • ~2~ — subscript2
  • $\alpha = \beta^2$ — LaTeX equations: \(\alpha = \beta^2\)
  • End a line with two spaces to start a new paragraph

Headings & cross-references

Headings

# Header1 {#anchor}
## Header 2

Jump to [Header 1](#anchor)

Footnotes

A footnote [^1]
[^1]: Here is the footnote.

Include images

![Caption](pathtoimage.png)

Lists and Bullets in markdown

 - Bullet 1
 - Bullet 2
  • Bullet 1
  • Bullet 2
 1. item 1
 2. item 2
  1. item 1
  2. item 2

Tables

| 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

Bibliography

---
bibliography: refs.bib
csl: style.csl
---

Smith cited [@smith04].
Smith cited without author [-@smith04].
@smith04 cited in line.

Additional resources

.qmd practical

👉 Your turn !

  1. create a new .qmd file
  2. play along with the various options described here
  3. try various output formats
  4. turn your answers to the first practical into a .qmd