Literate programming with the tidyverse

The tidyverse

The tidyverse is a collection of R packages designed for data science, as a suite aimed at easening the data analysis in all its steps.

All packages share an underlying design philosophy, grammar, and data structures.

Quarto

https://quarto.org/

Quarto

Allows to create

  • dynamic documents
  • presentations
  • web pages
  • books
  • scientific manuscripts

Quarto

Allows to mix prose with code

  • R
  • Python
  • Julia
  • Observable JS

markdown

markdown is a plain text format designed to be human readable but also easily machine formatted.

Any document in markdown can be read as a text file, but it can be also rendered to any rich document format (html, pdf-latex, docx…)

markdown basics

We are gonna follow the official guide:

https://quarto.org/docs/authoring/markdown-basics.html

Creating a quarto document (.qmd)

Creating a quarto document (.qmd)

frontmatter

Always at the beggining of the document. It allows to configure how is gonna be rendered.

---
title: "Untitled"
format: html
---

Creating a quarto document (.qmd)

HTML frontmatter options

---
title: "Olympic Games Analysis"
format:
  html:
    toc: true
    toc-title: "Contents"
    number-sections: true
    embed-resources: true
---

Creating a quarto document (.qmd)

PDF frontmatter options

---
title: "Olympic Games Analysis"
format:
  pdf:
    toc: true
    toc-title: "Contents"
    number-sections: true
---

Creating a quarto document (.qmd)

R code blocks

```{r}
library(dplyr)
library(ggplot2)
```

Creating a quarto document (.qmd)

R code blocks

```{r}
#| echo: false

1 + 1
```

Will render as:

[1] 2

Creating a quarto document (.qmd)

R code blocks

```{r}
#| echo: true

1 + 1
```

Will render as:

1 + 1
[1] 2

Creating a quarto document (.qmd)

Let’s start