23 Sep 2026
These materials are generated by Gerko Vink, who used to coordinate this course and holds the copyright. Gerko owes a debt of gratitude to many people as the thoughts and code in these slides are the process of years-long development cycles and discussions with his team, friends, colleagues and peers. When someone has contributed to the content of the slides, he has credited their authorship.
The intellectual property belongs to Utrecht University. Images are either directly linked, or generated with StableDiffusion or DALL-E. That said, there is no information in this presentation that exceeds legal use of copyright materials in academic settings, or that should not be part of the public domain.
Warning
You may use any and all content in this presentation - excluding names - and submit it as input to generative AI tools, with the following exception:
Open Source:
Markdown is a lightweight markup language for creating formatted text using plain text. It’s easy to learn and widely used in various applications.
Markdown is not WYSIWYG.
Instead, plain text with markup instructions are converted to marked up text (e.g., *italics* becomes italics).
Source: Markdown Guide
GitHub-Flavored Markdown (GFM) is a variant of Markdown used on GitHub (next week), enhancing its capabilities for documentation and collaboration.
Jupyter Notebooks: Widely used interactive kernel-based computing environment for data science and machine learning, supporting multiple (i.e. almost all) programming and scripting languages.
RMarkdown: An R-based notebook environment that allows you to embed R code and its output directly within a document; combining code, output, and narrative text in a single document.
Quarto: Next generation markdown for R, Python, Julia, etc. Perfect for creating reproducible reports, research papers, and presentations.
Popular IDEs for R:
YAML (YAML Ain’t Markup Language) is a human-readable data serialization format commonly used for configuration files and metadata in various programming and markup contexts.
YAML is very simple and readable
In Quarto and many other applications, YAML is used to specify:
Document Metadata: Information about the document itself, such as the title, author, date, and document type.
Document Configuration: Settings related to the document’s behavior, appearance, and rendering, such as the output format (e.g., HTML, PDF), document template, and style options.
Custom Variables: Definitions of custom variables or parameters that can be used throughout the document to control behavior or content.
The YAML header is a powerful tool for customizing and configuring Quarto documents, allowing you to control how the document is rendered and presented. It ensures that important document information and settings are stored in a human-readable and structured format at the beginning of the document.
title, author, and date provide metadata about the document.output specifies settings related to the document’s output format and theme.---
title: "All flavors markdown"
author:
- name: Gerko Vink
orcid: 0000-0001-9767-1924
email: g.vink@uu.nl
affiliations:
- name: Methodology & Statistics @ UU University
- name: Hanne Oberman
orcid: 0000-0003-3276-2141
email: h.i.oberman@uu.nl
affiliations:
- name: Methodology & Statistics @ UU
date: 25 Sep 2024
date-format: "D MMM YYYY"
bibliography: data/lec-2/publications.bib
execute:
echo: true
editor: source
format:
revealjs:
embed-resources: true
theme: [solarized, gerko.scss]
progress: true
multiplex: true
transition: fade
slide-number: true
margin: 0.075
logo: "images/logo.png"
toc: false
toc-depth: 1
toc-title: Outline
scrollable: true
reference-location: margin
footer: Gerko Vink and Hanne Oberman - Markup Languages @ UU
---Text is text. Nothing more, nothing less.
Headers are generated using #s
How would you generate these headers?
It is that simple. No more framing in \(\LaTeX\) or other stuff. Just use the # and ## to denote a section and a slide.
$\mu$ is used for in-line equations$$\mu$$ is used for equationsPlain text:
Let's assume that $Y$ follows a normal distribution.
$$Y \sim \mathcal{N}(\mu, \sigma^2)$$
Where we set in our simulations $\mu = 10$ and $\sigma^2 = 5$. We do something for every $Y_i$.
Marked up text:
Let’s assume that \(Y\) follows a normal distribution. \[Y \sim \mathcal{N}(\mu, \sigma^2)\] Where we set in our simulations \(\mu = 10\) and \(\sigma^2 = 5\). We do something for every \(Y_i\).
Plain text:
Let's assume that $y$ is a vector with $n$ elements such that
$$y \sim \mathcal{N}(\mu, \sigma^2),$$
where we set in our simulations $\mu = 10$ and $\sigma^2 = 5$.
We do something for every $y_i$ with $i = 1, \dots, n$.
Marked up text:
Let’s assume that \(y\) is a vector with \(n\) elements such that \[y \sim \mathcal{N}(\mu, \sigma^2),\] where we set in our simulations \(\mu = 10\) and \(\sigma^2 = 5\). We do something for every \(y_i\) with \(i = 1, \dots, n\).
Plain text:
Add a hyperlink to the Quarto documentation website,
showing the URL directly
<https://quarto.org/>
or with
[a description](https://quarto.org/).
Marked up text:
Add a hyperlink to the Quarto documentation website, showing the URL directly https://quarto.org/ or with a description.
Plain text:
Add an image from the internet

Marked up text:
Add an image from the internet
Plain text:
Add an image from your PC

Marked up text:
Add an image from your PC
Plain text:
Generate an image with code
```{r}
#| echo: false
plot(1:10)
```
Marked up text:
Generate an image with code
flowchart LR
A[Hard edge] --> B(Round edge)
B --> C{Decision}
C <--> D[Result one]
C --> E[Result two]
See Quarto Diagrams for a more comprehensive overview of all graphing engines. This Live online Mermaid editor is awesome!
Use tibbles (or gt) for static tables:
# A tibble: 748 × 9
age hgt wgt bmi hc gen phb tv reg
<dbl> <dbl> <dbl> <dbl> <dbl> <ord> <ord> <int> <fct>
1 0.035 50.1 3.65 14.5 33.7 <NA> <NA> NA south
2 0.038 53.5 3.37 11.8 35 <NA> <NA> NA south
3 0.057 50 3.14 12.6 35.2 <NA> <NA> NA south
4 0.06 54.5 4.27 14.4 36.7 <NA> <NA> NA south
5 0.062 57.5 5.03 15.2 37.3 <NA> <NA> NA south
6 0.068 55.5 4.66 15.1 37 <NA> <NA> NA south
7 0.068 52.5 3.81 13.8 34.9 <NA> <NA> NA south
8 0.071 53 3.89 13.8 35.8 <NA> <NA> NA west
9 0.071 55.1 3.88 12.8 36.8 <NA> <NA> NA west
10 0.073 54.5 4.2 14.1 38 <NA> <NA> NA east
# ℹ 738 more rows
Or use https://www.tablesgenerator.com/markdown_tables if you want to manually edit a static table.
Use library(DT) for interactive tables and customization:
Plain text:
```{r}
#| label: fig-one
#| fig-cap: Nonsense graph
#| echo: false
plot(1:10)
```
Used inline as @fig-one.
Plain text:
```{r}
#| label: tbl-penguins
#| tbl-cap: Penguins data
#| echo: false
gtsummary::tbl_summary(penguins)
```
Used inline as @tbl-penguins.
Marked up text:
| Characteristic | N = 3441 |
|---|---|
| species | |
| Adelie | 152 (44%) |
| Chinstrap | 68 (20%) |
| Gentoo | 124 (36%) |
| island | |
| Biscoe | 168 (49%) |
| Dream | 124 (36%) |
| Torgersen | 52 (15%) |
| bill_len | 44.5 (39.2, 48.5) |
| Unknown | 2 |
| bill_dep | 17.30 (15.60, 18.70) |
| Unknown | 2 |
| flipper_len | 197 (190, 213) |
| Unknown | 2 |
| body_mass | 4,050 (3,550, 4,750) |
| Unknown | 2 |
| sex | |
| female | 165 (50%) |
| male | 168 (50%) |
| Unknown | 11 |
| year | |
| 2007 | 110 (32%) |
| 2008 | 114 (33%) |
| 2009 | 120 (35%) |
| 1 n (%); Median (Q1, Q3) | |
Used inline as Table 1.
References require a bibliography entry, such as in a .bib file:
@book{ref,
title = {Name of the book (or article, etc.)},
author = {Lastname, Firstname},
year = {2026}
}
.bib file, links them by citation keys, and formats output with a selected bibliography style..bib file’s role is to store bibliographic records, and only entries that have been cited* will appear in the reference list.* e.g., via \cite{...} in .tex files, or @... in Quarto
Zotero [zoh-TAIR-oh] is a free, easy-to-use tool to help you collect, organize, cite, and share your research sources. - Zotero’s quick start guide
Log InLog InRegister for a free accountLog InRegister for a free accountLog InRegister for a free accountRegisterShare \(\rightarrow\) Zotero app.xpi file for the version you want
Save Link As...
Boolean for browser.altClickSave to true at about:configTools \(\rightarrow\) PluginsInstall Plugins From File….xpi files to installOpenInstallDownload and install Zotero plugins (as .xpi files) to get:
Marked up text:
Oberman and Vink (2023) and Cai, Van Buuren and Vink (2023) are some of our team’s most recent publications. Some references - such as some work by Reinder Banning and Gerko Vink are much older (2010) or contain simple and contemporary solutions by Volker and Vink (2022, 2–4) or cool but potentially confusing images (Schouten and Vink 2021, 1255).
Plain text:
@eval and Cai, Van Buuren and Vink [-@cai2023graphical] are some of our team's most recent publications. Some references - such as some work by Reinder Banning and Gerko Vink are much older [-@banningvink] or contain simple and contemporary solutions by @vigntg [p. 2-4] or cool but potentially confusing images [@schouten2021dance, 1255].
::: footer
But you can also refer to @eval here
:::
But you can also refer to Oberman and Vink (2023) here
Marked up text:
Plain text:
::: {#refs}
:::
The above figure is left-aligned
The caption is also left-aligned
The above figure is centered
The caption is still left-aligned
The code for the figures is
\(e^{i\pi} + 1 = 0\)
The above figure is left-aligned
The caption is also left-aligned
The equation is left-aligned too
\[e^{i\pi} + 1 = 0\]
The above figure is centered
The caption is also centered
The equation is centered
The code for the slide is
## Columns, Sizing, Equations and proper centering
::: columns
::: {.column width="50%"}
{fig-align="left" width="80%"}
$e^{i\pi} + 1 = 0$
The above figure is left-aligned <br>
The caption is also left-aligned <br>
The equation is left-aligned too
:::
::: {.column width="50%"}
<center>
{fig-align="center" width="80%"}
</center>
$$e^{i\pi} + 1 = 0$$
The above figure is centered <br>
The caption is also centered <br>
The equation is centered
:::
:::
The code for the slide is
``` markdown
## Columns, Sizing, Equations and proper centering
::: columns
::: {.column width="50%"}
{fig-align="left" width="80%"}
$e^{i\pi} + 1 = 0$
The above figure is left-aligned <br>
The caption is also left-aligned <br>
The equation is left-aligned too
:::
::: {.column width="50%"}
<center>
{fig-align="center" width="80%"}
</center>
$$e^{i\pi} + 1 = 0$$
The above figure is centered <br>
The caption is also centered <br>
The equation is centered
:::
:::\(e^{i\pi} + 1 = 0\)
The above figure is left-aligned
The caption is also left-aligned
The equation is left-aligned too
\[e^{i\pi} + 1 = 0\]
The above figure is centered
The caption is also centered
The equation is centered
\(e^{i\pi} + 1 = 0\)
\[e^{i\pi} + 1 = 0\]
## Math-ing it all up
::: columns
::: {.column width="70%"}
{fig-align="left" width="30%"}
$e^{i\pi} + 1 = 0$
:::
::: {.column width="30%"}
<center>
{fig-align="center" width="70%"}
</center>
$$e^{i\pi} + 1 = 0$$
:::
:::
```markdown
END OF EXAMPLE
We already saw some markdown code chunks. We can run inline code to calculate that 12 * 234 is 2808 by using `r ` and code chunks to evaluate larger blocks of code, such as:
We already saw some `markdown` code chunks. We can run inline code to calculate
that `12 * 234` is ` r answer ` by using `r ` and code chunks to evaluate
larger blocks of code, such as:
```{{r}}
#| output: asis
#| label: fig-mpg
#| fig-cap: "City and highway mileage for 38 popular models of cars."
#| fig-subcap:
#| - "Color by number of cylinders"
#| - "Color by engine displacement, in liters"
#| layout-ncol: 2
#| column: page
#| code-fold: true
library(ggplot2)
ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
geom_point(alpha = 0.5, size = 2) +
scale_color_viridis_c() +
theme_minimal()
ggplot(mpg, aes(x = hwy, y = cty, color = displ)) +
geom_point(alpha = 0.5, size = 2) +
scale_color_viridis_c(option = "E") +
theme_minimal()
```Efficiency: Caching saves time and resources by avoiding the repeated execution of time-consuming code chunks.
Reproducibility: Explicit caching ensures that the same results are used when rendering the document, even if the code is modified or re-executed.
Version Control: Caching reduces the size of version-controlled documents by storing intermediate results separately.
In RMarkdown and Quarto, you can use cache directives to specify which code chunks should be cached and which should not.
Cached chunks are identified by a unique hash based on their code content, ensuring consistency.
The following code block
would result in this output
Class: mipo m = 5
term m estimate ubar b t dfcom
1 (Intercept) 5 21.27602717 18.759034078 2.413095e+00 2.165475e+01 22
2 chl 5 0.03133399 0.000449016 7.865769e-05 5.434052e-04 22
3 hyp 5 -0.81540952 3.747114358 9.352609e-01 4.869427e+00 22
df riv lambda fmi
1 16.25906 0.1543637 0.1337219 0.2236825
2 14.85089 0.2102135 0.1736995 0.2662776
3 12.90561 0.2995140 0.2304815 0.3272422
with corresponding cache structure relative to the root and format of the output file:
\(\rightarrow\) topic lecture 4
reprex and renvlibrary(renv)
#>
#> Attaching package: 'renv'
#> The following objects are masked from 'package:stats':
#>
#> embed, update
#> The following objects are masked from 'package:utils':
#>
#> history, upgrade
#> The following objects are masked from 'package:base':
#>
#> autoload, load, remove
renv::init()
#> - Linking packages into the project library ... Done!
#> The following package(s) will be updated in the lockfile:
#>
#> # CRAN -----------------------------------------------------------------------
#> - backports [* -> 1.4.1]
#> - base64enc [* -> 0.1-3]
#> - broom [* -> 1.0.4]
#> - bslib [* -> 0.4.2]
#> - cachem [* -> 1.0.8]
#> - cli [* -> 3.6.1]
#> - cpp11 [* -> 0.4.3]
#> - digest [* -> 0.6.31]
#> - dplyr [* -> 1.1.2]
#> - ellipsis [* -> 0.3.2]
#> - evaluate [* -> 0.21]
#> - fansi [* -> 1.0.4]
#> - fastmap [* -> 1.1.1]
#> - fontawesome [* -> 0.5.1]
#> - fs [* -> 1.6.2]
#> - generics [* -> 0.1.3]
#> - glue [* -> 1.6.2]
#> - highr [* -> 0.10]
#> - htmltools [* -> 0.5.5]
#> - jquerylib [* -> 0.1.4]
#> - jsonlite [* -> 1.8.4]
#> - knitr [* -> 1.43]
#> - lattice [* -> 0.21-8]
#> - lifecycle [* -> 1.0.3]
#> - magrittr [* -> 2.0.3]
#> - memoise [* -> 2.0.1]
#> - mime [* -> 0.12]
#> - pillar [* -> 1.9.0]
#> - pkgconfig [* -> 2.0.3]
#> - purrr [* -> 1.0.1]
#> - R6 [* -> 2.5.1]
#> - rappdirs [* -> 0.3.3]
#> - Rcpp [* -> 1.0.11]
#> - RcppArmadillo [* -> 0.12.4.0.0]
#> - renv [* -> 1.0.2]
#> - rlang [* -> 1.1.1]
#> - rmarkdown [* -> 2.22]
#> - sass [* -> 0.4.6]
#> - stringi [* -> 1.7.12]
#> - stringr [* -> 1.5.0]
#> - tibble [* -> 3.2.1]
#> - tidyr [* -> 1.3.0]
#> - tidyselect [* -> 1.2.0]
#> - tinytex [* -> 0.45]
#> - utf8 [* -> 1.2.3]
#> - vctrs [* -> 0.6.2]
#> - withr [* -> 2.5.0]
#> - xfun [* -> 0.39]
#> - yaml [* -> 2.3.7]
#>
#> # GitHub ---------------------------------------------------------------------
#> - mice [* -> gerkovink/mice@match_conditional]
#>
#> The version of R recorded in the lockfile will be updated:
#> - R [* -> 4.3.0]
#>
#> - Lockfile written to "/private/var/folders/yx/6rn4qpl13wsgk4c7s3jc9d1r0000gp/T/RtmpMqetyA/reprex-1233f6d959b19-drear-kitty/renv.lock".
library(mice)
#>
#> Attaching package: 'mice'
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following objects are masked from 'package:base':
#>
#> cbind, rbind
library(magrittr)
library(purrr)
#>
#> Attaching package: 'purrr'
#> The following object is masked from 'package:magrittr':
#>
#> set_names
#> The following object is masked from 'package:renv':
#>
#> modify
renv::snapshot()
#> - The lockfile is already up to date.
renv::remove("mice")
#> - Removing package(s) from project library ...
#> Removing package 'mice' ... Done!
renv::restore()
#> The following package(s) will be updated:
#>
#> # GitHub ---------------------------------------------------------------------
#> - mice [* -> gerkovink/mice@match_conditional]
#>
#> # Installing packages --------------------------------------------------------
#> - Installing mice ... OK [linked from cache]
imp <- nhanes |> mice(print = FALSE)
imp |>
complete("all") |>
map(~.x %$% lm(bmi ~ chl + hyp)) |>
pool()
#> Class: mipo m = 5
#> term m estimate ubar b t dfcom
#> 1 (Intercept) 5 20.6687887 2.020809e+01 8.8963873222 3.088375e+01 22
#> 2 chl 5 0.0354435 5.409979e-04 0.0001081414 6.707676e-04 22
#> 3 hyp 5 -0.8447582 4.353337e+00 0.9275040571 5.466342e+00 22
#> df riv lambda fmi
#> 1 9.489411 0.5282868 0.3456725 0.4504537
#> 2 14.161181 0.2398710 0.1934645 0.2874598
#> 3 13.811544 0.2556671 0.2036105 0.2983537
sessionInfo()
#> R version 4.3.0 (2023-04-21)
#> Platform: aarch64-apple-darwin20 (64-bit)
#> Running under: macOS Ventura 13.6
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> time zone: Europe/Amsterdam
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] purrr_1.0.1 magrittr_2.0.3 mice_3.15.3 renv_1.0.2
#>
#> loaded via a namespace (and not attached):
#> [1] vctrs_0.6.2 cli_3.6.1 knitr_1.43 rlang_1.1.1
#> [5] xfun_0.39 generics_0.1.3 glue_1.6.2 backports_1.4.1
#> [9] htmltools_0.5.5 fansi_1.0.4 rmarkdown_2.22 grid_4.3.0
#> [13] evaluate_0.21 tibble_3.2.1 fastmap_1.1.1 yaml_2.3.7
#> [17] lifecycle_1.0.3 compiler_4.3.0 dplyr_1.1.2 fs_1.6.2
#> [21] pkgconfig_2.0.3 Rcpp_1.0.11 tidyr_1.3.0 rstudioapi_0.14
#> [25] lattice_0.21-8 digest_0.6.31 R6_2.5.1 tidyselect_1.2.0
#> [29] reprex_2.0.2 utf8_1.2.3 pillar_1.9.0 tools_4.3.0
#> [33] withr_2.5.0 broom_1.0.4Created on 2023-09-27 with reprex v2.0.2
renv1. Dependency Isolation: renv creates a dedicated environment for each project, preventing conflicts between package versions.
2. Reproducibility: With renv, you can capture and record the specific package versions used in your project, ensuring reproducibility over time.
3. Collaboration: Share your project with others, and they can easily recreate the same environment using renv.lock.
4. Easier Package Installation: renv simplifies package installation. Just run renv::restore() to set up the project environment.
5. Automatic Snapshot: renv automatically generates a renv.lock file, listing all package versions used, making it easy to recreate the environment.
6. Compatibility: renv is compatible with popular version control systems like Git, facilitating collaboration and sharing.
Use renv::snapshot() to update the renv.lock file when you add or update packages. You can use renv::activate() and renv::deactivate() to activate or deactivate renv for your project.
rticles and QuartoTo use rticles from RStudio, you can access the templates through File -> New File -> R Markdown. This will open the dialog box where you can select from one of the available templates:
The quarto use template command can be used to create an article from one the below formats.
Pablo Mosteiro and Hanne Oberman - Markup Languages @ UU