-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.Rmd
44 lines (36 loc) · 1.29 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
date: "`r Sys.time()`"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.path = "assets/plots/")
source("init.R")
theme_set(tadaatoolbox::theme_tadaa(bg = "#ffffff"))
```
## Distribution
```{r distribution}
btw17 %>%
select(Bundesland, `Wahlberechtigte (A)`, `Wähler (B)`, `Ungültige`:`V-Partei³`) %>%
gather(key = Partei, value = Stimmen, CDU:`V-Partei³`) %>%
group_by(Partei) %>%
summarise(Prozent = sum(Stimmen) / sum(`Gültige`)) %>%
mutate(Parteien = ifelse(Prozent <= .05, "Sonstige", Partei)) %>%
ggplot(aes(x = reorder(Parteien, -Prozent), y = Prozent, fill = Parteien)) +
geom_col() +
scale_y_continuous(labels = scales::percent) +
scale_fill_manual(guide = FALSE, values = partei_colors) +
labs(title = "Stimmanteil aller Parteien bundesweit", x = "Partei", y = "Stimmanteil")
```
### Distribution by State
```{r distribution_by_state}
btw_long %>%
ggplot(aes(x = reorder(Parteien, Prozent), y = Prozent, fill = Parteien)) +
geom_col() +
scale_y_continuous(labels = scales::percent) +
scale_fill_manual(breaks = names(partei_colors), values = partei_colors) +
labs(title = "Stimmanteil aller Parteien >5% pro Bundesland") +
facet_wrap(~ Bundesland) +
coord_flip()
```