Show the code
vis_miss(soldiers)
gg_miss_upset(soldiers)
Steen Flammild Harsted & Søren O´Neill
April 25, 2025
You can download the course slides for this section here
source(here("scripts", "01_import.R"))
in the chunklibrary(naniar)
to the code chunk where you load your librariesIf you need to install naniar
:
install.packages("naniar")
to download the naniar
package.starwars
usingvis_miss()
gg_miss_upset()
, nsets = 6
inside gg_miss_upset()
naniar
contains more useful functions. You can see them here ::: {.cell}:::
soldiers
dataset---
title: "Missing data"
author: "Steen Flammild Harsted & Søren O´Neill"
date: today
format:
html:
toc: true
toc-depth: 2
number-sections: true
number-depth: 2
code-fold: true
code-summary: "Show the code"
code-tools: true
execute:
eval: false
message: false
warning: false
---
<br><br>
# Presentation
You can download the course slides for this section <a href="./presentation_missing_data.html" download>here</a>
<div>
```{=html}
<iframe class="slide-deck" src="presentation_missing_data.html" width=90% ></iframe>
```
</div>
```{r setup}
#| include: false
library(tidyverse)
library(here)
library(naniar)
source(here("scripts", "01_import.R"))
```
```{r}
#| eval: true
#| column: margin
#| echo: false
knitr::include_graphics(here::here("img", "sherif.png"))
```
## Getting Started {.unnumbered}
* Make sure that you are working in your course project
* Create a new quarto document and name it "missings.qmd"
* Insert a code chunk and load 2 important libraries
* Insert a new code chunk- Write `source(here("scripts", "01_import.R"))` in the chunk
* Write a short headline to each code chunk
* Change the YAML header to style your document output.
::: {.callout-tip collapse="true"}
### The YAML header can look like this
````{verbatim}
---
title: "TITLE"
subtitle: "SUBTITLE"
author: "ME"
date: today
format:
html:
toc: true
toc-depth: 2
embed-resources: true
number-sections: true
number-depth: 2
code-fold: true
code-summary: "Show the code"
code-tools: true
execute:
message: false
warning: false
---
````
:::
<br><br>
## Missing Data
<br><br>
### add `library(naniar)` to the code chunk where you load your libraries
If you need to install `naniar`:
* use `install.packages("naniar")` to download the `naniar` package.
* This is done in the console and NOT in your script.
<br><br>
### Explore missing values in `starwars` using
* `vis_miss()`
* `gg_miss_upset()`
* What happens if you add `, nsets = 6` inside `gg_miss_upset()`
* `naniar` contains more useful functions. You can see them [here](https://cran.r-project.org/web/packages/naniar/vignettes/naniar-visualisation.html)
```{r}
#| output: false
vis_miss(starwars)
gg_miss_upset(starwars)
```
<br><br>
### Explore missing values in the `soldiers` dataset
```{r}
#| output: false
vis_miss(soldiers)
gg_miss_upset(soldiers)
```
<br><br>
### Improve your home assignment
* Go back to your home assignment and add a section where you explore missing values
* Remember to change project (top right corner in Rstudio)
* Using the menu in the top right corner, you can switch between your course project and your home assignment