```{r}
1 + 1
```
[1] 2
With the Help from knitr
, Markdown and Quarto
Hochschule für Musik, Theater und Medien – Hannover
Institut für Musikphysiologie und Musiker-Medizin
2024-11-29
Re-run the analysis with the same data and get the same result
Different files for different tasks (read_data.R
, EDA.R
, data_wrangling.R
, etc.)?
Several scripts with numbered filenames (01_read_data.R
, 02_EDA.R
, etc.)?
One script with sections for each task?
When preparing & writing your scripts keep in mind
Don Knuth
1981: WEB
---
title: "Markdown Example Page"
format: html
---
This is an example page to document some of the easy formatting instructions used in Markdown.
# Headers
## More Headers
### Even More Headers
# Line-breaks
A line-break
is introduced by two(!) line-breaks in the source text:
Or by two trailing spaces:
But beware, the spaces may be missed when reading the source text, which can be confusing to the reader!
# Lists
## Unordered Lists
* An Item
* Another item
* Yet another one
## Ordered Lists{#ordered-lists}
1. First item
2. Second item
# Fonts etc.
The *different* **fonts** of a typeface ~~were already introduced~~are shown here, but there's more to markup your writing:
* superscript^2^
* subscript~i~
* Preformatted (typewriter) text:
`This is a typewriter face`
* LaTeX equations
* Inline: $\sum_{n=1}^{k} x_n^2$
* Display:
$$\sum_{n=1}^{k} x_n^2$$
# Tables
First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell
# Images

# Links
In-line references, e.g. [Ordered Lists](#ordered-lists), as well as links to the WWW are easy to write (and read!): Wikipedia page on [literate programming](https://en.wikipedia.org/wiki/Literate_programming).
knitr
knitr
facilitates the integration of R code and R output into a document:
knitr
and Markdown Example Page---
title: "`knitr` and Markdown Example Page"
format: html
---
A simple calculation in R:
Inline-usage of R variables:
The average value ($\pm$ SD) amounted to `{r} Mean` (`{r} StandardDeviation`) units.
The library `knitr` contains some nifty functions to, e.g., output data.frames as tables:
len | supp | dose |
---|---|---|
4.2 | VC | 0.5 |
11.5 | VC | 0.5 |
7.3 | VC | 0.5 |
5.8 | VC | 0.5 |
6.4 | VC | 0.5 |
10.0 | VC | 0.5 |
11.2 | VC | 0.5 |
11.2 | VC | 0.5 |
5.2 | VC | 0.5 |
7.0 | VC | 0.5 |
16.5 | VC | 1.0 |
16.5 | VC | 1.0 |
15.2 | VC | 1.0 |
17.3 | VC | 1.0 |
22.5 | VC | 1.0 |
17.3 | VC | 1.0 |
13.6 | VC | 1.0 |
14.5 | VC | 1.0 |
18.8 | VC | 1.0 |
15.5 | VC | 1.0 |
23.6 | VC | 2.0 |
18.5 | VC | 2.0 |
33.9 | VC | 2.0 |
25.5 | VC | 2.0 |
26.4 | VC | 2.0 |
32.5 | VC | 2.0 |
26.7 | VC | 2.0 |
21.5 | VC | 2.0 |
23.3 | VC | 2.0 |
29.5 | VC | 2.0 |
15.2 | OJ | 0.5 |
21.5 | OJ | 0.5 |
17.6 | OJ | 0.5 |
9.7 | OJ | 0.5 |
14.5 | OJ | 0.5 |
10.0 | OJ | 0.5 |
8.2 | OJ | 0.5 |
9.4 | OJ | 0.5 |
16.5 | OJ | 0.5 |
9.7 | OJ | 0.5 |
19.7 | OJ | 1.0 |
23.3 | OJ | 1.0 |
23.6 | OJ | 1.0 |
26.4 | OJ | 1.0 |
20.0 | OJ | 1.0 |
25.2 | OJ | 1.0 |
25.8 | OJ | 1.0 |
21.2 | OJ | 1.0 |
14.5 | OJ | 1.0 |
27.3 | OJ | 1.0 |
25.5 | OJ | 2.0 |
26.4 | OJ | 2.0 |
22.4 | OJ | 2.0 |
24.5 | OJ | 2.0 |
24.8 | OJ | 2.0 |
30.9 | OJ | 2.0 |
26.4 | OJ | 2.0 |
27.3 | OJ | 2.0 |
29.4 | OJ | 2.0 |
23.0 | OJ | 2.0 |
Quarto
For instance
--
and ---
Pros:
Cons:
knitr
and QuartoIMMM 2024