Applied Statistics – A Practical Course
2025-09-16
The slides were created with Quarto using Rstudio and R.
Use cursor keys for navigation, press O for a slide Overview
Markdown .md
RMarkdown .Rmd
Quarto .qmd
Quick note taking (documentation of ideas, experiments, SOPs, …)
Documentation of statistical analyses (Quarto + R)
Clearly structured documents (outline clearly visible)
Easy literature referencing
Much easier than LaTeX
Widely used technology, useful for Stackoverflow, Github or Matrix
Panwriter with live preview
RStudio
Section titles are introduced with one or several hash symbols #
, ##
, praragraphs with empty lines, italic and bold face are indicated with one or two starts before and after a phrase, bullet points with a leading dash -
or a star *
. Weblinks are automatically activated. Here an example:
# First level
Text can be written with any editor, that can be formatted, e.g. *slanted*, **boldface**,
`verbatim text` weblinks: https://tu-dresden.de or bullet points:
* point 1
* point 2
Section titles start with one or more hash tags
## Second level
### Third level
There are of course more formatting options, found in the docs or explained later.
Quarto and markdown documents can have a few special lines on top, enclosed within three dashes ---
. This so called “YAML header” is used to set text settings and formatting options:
---
title: "Test"
author: "Who wrote this"
date: '2024-11-12'
format: html
---
# First Section
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat.
At vero eos et accusam et justo duo dolores et ea rebum.
# Second Section
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
dolor sit amet.
YAML: yet another markup language. A list format coming from the python world.
Rendering is done with the pandoc utility to convert Quarto or Markdown text to
HTML for web pages, pdf for printing, or Word for further editing.
::: {.cell}
:::
… or by installing tinytex from the Terminal of RStudio
quarto install tinytex
and then include format: pdf
in the YAML header
title: "My document"
format: pdf
See more at: https://quarto.org/docs/output-formats/pdf-basics.html
Section titles can be formatted with hashtags or by underlining:
# A Section
## A subsection
or:
A Section
=========
A Subsection
------------
Automatic numbering can optionally be enabled in the YAML header:
---
title: "My document"
format:
html:
toc: true
number-sections: true
---
[further reading](https://rmarkdown.rstudio.com)
is then formatted as: further reading
The [*Markdown Wikipedia page*](https://de.wikipedia.org/wiki/Markdown) contains examples.
The Markdown Wikipedia page contains examples.
Images are similar to weblinks, but with a leading !

figure title
Verbatim text can be created with several methods:
`verbatim text`
\(\rightarrow\) verbatim text
```
before and after a tect or code block.```
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua.
```
appears as:
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua.
Source code:
| Right | Left | Default | Center |
|------:|:-----|---------|:------:|
| 12 | 34 | 56 | 78 |
| this | is | a | table |
HTML Output:
Right | Left | Default | Center |
---|---|---|---|
12 | 34 | 56 | 78 |
this | is | a | table |
PDF output:
Bigger or more complex tables: create the table in Excel or LibreOffice and add markdown formatting, or use R and kable
to create the table from data.
.bib
-format, e.g. references.bib
@bib_key
-syntax@APA2020b
[@APA2020a]
bibliography: references.bib
csl: apa
.csl
-style e.g. apa.csl
, that is copied to the folder of the documentMarkdown and Quarto support a subset of the LaTeX formula syntax
$s_x = \frac{\sum_{i=1}^{N} (x_i - \bar{x})^2}{N-1}$
\(\quad \rightarrow \qquad s_x = \frac{\sum_{i=1}^{N} (x_i - \bar{x})^2}{N-1}\)
#### Display formula
$$s_x = \frac{\sum_{i=1}^{N} (x_i - \bar{x})^2}{N-1}$$
\[s_x = \frac{\sum_{i=1}^{N} (x_i - \bar{x})^2}{N-1}\]
\(\rightarrow, \le, \approx, \mu, \delta, \int, \infty, \mathrm{m^3s^{-1}}\)
$\rightarrow, \le, \approx, \mu, \delta, \int, \infty, \mathrm{m^3s^{-1}}$
\[\begin{align} \frac{dX_1}{dt} &= k_1 \cdot X_1 - k_2 X_1 X_2 \\ \frac{dX_2}{dt} &= - k_4 \cdot X_2 + k_3 X_1 X_2 \\ \end{align}\]
\begin{align}
\frac{dX_1}{dt} &= k_1 \cdot X_1 - k_2 X_1 X_2 \\
\frac{dX_2}{dt} &= k_3 X_1 X_2 - k_4 \cdot X_2 \\
\end{align}
\[\rm 6CO_2 + 6H_2O \rightarrow C_6H_{12}O_6 + 6O_2 \quad \Delta H^0 = +2870 kJ mol^{-1}\]
$$\rm 6CO_2 + 6H_2O \rightarrow C_6H_{12}O_6 + 6O_2 \quad \Delta H^0 = +2870 kJ mol^{-1}$$
Create a Quarto template from the File menu in RStudio. Then make your changes and click the Render button. Then, a document will be generated that includes both content as well as the output of any embedded R code chunks.
Then embed your own R code chunks like this:
```{r iris_summary}
summary(iris)
```
To show both, the code and the output
Sepal.Length Sepal.Width Petal.Length Petal.Width
Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100
1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300
Median :5.800 Median :3.000 Median :4.350 Median :1.300
Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
Species
setosa :50
versicolor:50
virginica :50
If you want to include real tables, you can create the table in R and then format it with knitr::kable
```{r iris_table}
knitr::kable(iris[1:4, ])
```
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
The kable
function has several functions for configuring table layout, see kable
help page for details.
You can also embed plots, for example:
```{r iris_sepal}
plot(Sepal.Width ~ Sepal.Length, data=iris, pch=16, col=Species)
```
The code chunks can be modified with additional options. In the following example the figure size is adjusted and an option echo = FALSE
was added to prevent printing of the R code that generated the plot.
```{r iris_sepal3, fig.width=3, fig.height=3, echo=FALSE}
plot(Sepal.Width ~ Sepal.Length, data=iris, pch=16, col=Species)
```
Shows the plot without the code:
… can be created with the DiagrammeR package that supports the graphviz language.
library("DiagrammeR")
grViz("digraph pandoc {
graph [rankdir = LR]
node [shape = 'box']
Markdown HTML PDF Word
node [shape = cds]
pandoc
node [shape = oval]
figs bib
edge [penwidth=2]
Markdown -> pandoc
{figs bib} -> {pandoc}
pandoc -> {HTML PDF Word}
}")
More at: https://graphviz.org/
\(\rightarrow\) Quarto cheat sheet
For more details, see https://quarto.org and R Core Team (2024)“, RStudio Team (2021), Xie (2015) and The Quarto Dev Team (2024).
Thesis templates for Hydrobiology students at TU Dresden: https://github.com/tpetzoldt/hyb-tud-thesis-starterkit in Word, Latex and Quarto format. It may also be useful for you.