Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

normalfordeling på engelsk! #196

Merged
merged 7 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ episodes:
- github-and-you.Rmd
- plot-with-tidyplot.Rmd
- anova.Rmd
- missing-data.Rmd
- adv-dataviz.Rmd
- digitizing-graphs.Rmd

# Information for Learners
learners:
Expand Down
138 changes: 138 additions & 0 deletions episodes/adv-dataviz.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
title: 'Advanced datavisualisation'
teaching: 10
exercises: 2
---

:::::::::::::::::::::::::::::::::::::: questions

- How do you write a lesson using R Markdown and `{sandpaper}`?

::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::: objectives

- Explain how to use markdown with the new lesson template
- Demonstrate how to include pieces of code, figures, and nested challenge blocks

::::::::::::::::::::::::::::::::::::::::::::::::

## Introduction
or rather, weird and wonderfull stuff found in ggplot2.

As almost everything else in the programming world - these notes have
been "borrowed" from others.

https://github.com/teunbrand/ggplot_tricks - take a look, new stuff might have
appeared.

https://erikgahner.dk/2022/tips-and-tricks-for-ggplot2/

https://www.epirhandbook.com/new_pages/ggplot_tips.html

Gør kun tingene en gang.

theme_set tillader os at sætte et bestemt tema for alle efterfølgende plot.

```{r}
library(tidyverse)
library(palmerpenguins)
```


```{r}
theme_set(
theme_bw()
)
```


```{r}
penguins %>%
ggplot(aes(body_mass_g, flipper_length_mm)) +
geom_point()
```

Den der aes() funktion - hvad gør den egentlig?

```{r}
my_mapping <- aes(x = wt, y = mpg)
my_mapping
```
Det giver jo fin mening - x i plottet skal mappes til "wt", og y til "mpt".

Hvad ellers?

```{r}
class(my_mapping)
```
uneval? wtf?! Nærlæser man, finder man ud af at det er en klasse der bruges til at
gemme udtryk der ikke er evaluerede, men som skal evalueres i en bestemt kontekst.


```{r}
str(my_mapping)
```
Ikke overraskende er det en liste. Det er det ofte.

det kan man godt dykke dybere ned i.

Nå. Men my_mapping er altså en samling af uevaluerede udtryk, samlet i en
liste.

Ønsker vi at pille dem ud, kan vi "splice" dem.

det kan vi dog kun i bestemte kontekster. den interessante er aes:

```{r}
aes(!!!my_mapping)
```
Det gør det muligt at sætte flere sammen:

```{r}
my_other_mapping <- aes(color = am)
```

```{r}
aes(!!!my_mapping, !!!my_other_mapping)
```


```{r}
mtcars %>% ggplot(aes(!!!my_mapping)) + geom_point()
```


Det tillader os at sætte forskellige mappings sammen:

```{r}
my_other_mapping <- aes(colour = qux)
aes(!!!my_mapping, !!!my_other_mapping)
```

Og hvad kan man bruge det til?

Her er et eksempel, der bruger et andet trick:


my_fill <- aes(fill = after_scale(alpha(colour, 0.3)))

ggplot(mpg, aes(displ, hwy)) +
geom_point(aes(colour = factor(cyl), !!!my_fill), shape = 21)


after_scale() giver forsinket evaluering. her evalueres det efter der er
kørt en scalering på factoren. Og som sætter fill til den farve som
geom_point har valgt for os - med en justering af alpha. Det ser neat ud!



::::::::::::::::::::::::::::::::::::: keypoints

- Use `.md` files for episodes when you want static content
- Use `.Rmd` files for episodes when you need to generate output
- Run `sandpaper::check_lesson()` to identify any issues with your lesson
- Run `sandpaper::build_lesson()` to preview your lesson locally

::::::::::::::::::::::::::::::::::::::::::::::::

6 changes: 6 additions & 0 deletions episodes/design-principles.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exercises: 2

::::::::::::::::::::::::::::::::::::::::::::::::

se også: https://ikashnitsky.phd/2024/rotate-damn-plot/

```{r setup}
library(tidyverse)
Expand Down Expand Up @@ -144,6 +145,11 @@ the area of the slices.

Except when they shouldn't.

A common rule of thumb is that axes should always start at 0.

However. If the axis does not have a natural 0 - do not.


Langt, langt de fleste gange skal aksen starte med 0.
Men ikke hvis aksen ikke har et naturligt 0 punkt. Den klassiske om gennemsnitlig
højde af kvinder.
Expand Down
39 changes: 39 additions & 0 deletions episodes/digitizing-graphs.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: 'digitizing-graphs'
teaching: 10
exercises: 2
---

:::::::::::::::::::::::::::::::::::::: questions

- How do you write a lesson using R Markdown and `{sandpaper}`?

::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::: objectives

- Explain how to use markdown with the new lesson template
- Demonstrate how to include pieces of code, figures, and nested challenge blocks

::::::::::::::::::::::::::::::::::::::::::::::::

## Introduction

Hvordan får man fat på data fra en graf?

```{r eval =FALSE}
digitize("fig/plot-to-redo.jpg")
```




::::::::::::::::::::::::::::::::::::: keypoints

- Use `.md` files for episodes when you want static content
- Use `.Rmd` files for episodes when you need to generate output
- Run `sandpaper::check_lesson()` to identify any issues with your lesson
- Run `sandpaper::build_lesson()` to preview your lesson locally

::::::::::::::::::::::::::::::::::::::::::::::::

Binary file added episodes/fig/plot-to-redo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added episodes/fig/woman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions episodes/missing-data.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: 'missing-data'
teaching: 10
exercises: 2
---

:::::::::::::::::::::::::::::::::::::: questions

- How do you write a lesson using R Markdown and `{sandpaper}`?

::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::: objectives

- Explain how to use markdown with the new lesson template
- Demonstrate how to include pieces of code, figures, and nested challenge blocks

::::::::::::::::::::::::::::::::::::::::::::::::

## Introduction
tre slags manglende data.

* Missing completely at random
* Missing at random
* Missing not at random

Tilgange

listwise deletion. Vi sender spørgeskemaer ud. og ikke alle svarer.
Dem sletter vi. Nogen svarer ikke på alle spørgsmål. Dem sletter vi også.
Vi kunne også kalde det for "complete case analysis" - vi analyserer kun
på de komplette cases.

pairwise deletion

Imputationer

Hot deck imputation

mean substitution. Dårlig ide

regressions subsistitution. Lidt bedre. Men ikke god.

Multiple imputation - lader til at være god.
maximum likelihood imputation


::::::::::::::::::::::::::::::::::::: keypoints

- Use `.md` files for episodes when you want static content
- Use `.Rmd` files for episodes when you need to generate output
- Run `sandpaper::check_lesson()` to identify any issues with your lesson
- Run `sandpaper::build_lesson()` to preview your lesson locally

::::::::::::::::::::::::::::::::::::::::::::::::

Loading
Loading