Created
February 3, 2024 20:55
-
-
Save conjugateprior/ed75d95287314aaa963c518b08a430a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Download data from here: https://taz.de/Proteste-gegen-Rechtsextremismus/!5988174/ | |
| library(tidyverse) | |
| # first version with police data | |
| fl <- "~/Downloads/data-Q5MHN.csv" | |
| dd <- read_csv(fl) |> | |
| mutate(Ort = trimws(Ort), | |
| date = as.Date(Datum, format = "%d.%m.%Y"), | |
| pcount = `Teilnehmende laut Polizei`, | |
| pcount = ifelse(is.na(pcount), 0, pcount)) |> | |
| select(Ort, date, pcount) | |
| dd |> | |
| filter(date > as.Date("2024-01-15")) |> | |
| group_by(date) |> | |
| summarize(n = sum(pcount)) |> | |
| ggplot(aes(date, n/100000)) + | |
| geom_col(fill = "dark grey") + | |
| labs(y = "Participants in 100,000s", | |
| x = "Date", | |
| title = "Anti-AfD Demo Participants (Police Numbers)", | |
| subtitle = "Source: https://taz.de/Proteste-gegen-Rechtsextremismus/!5988174/") + | |
| theme_minimal() | |
| # updated version with lower and sometimes upper bounds on counts | |
| fl <- "~/Downloads/data-KzD0F.csv" | |
| dd <- read_csv(fl) |> | |
| mutate(Ort = trimws(Ort), | |
| date = as.Date(Datum, format = "%d.%m.%Y"), | |
| lcount = `Mindestangabe Teilnehmerzahl`, # take the lower | |
| lcount = ifelse(is.na(lcount), 0, lcount), | |
| ucount = `Höchstangabe Teilnehmerzahl`, | |
| ucount = ifelse(is.na(ucount), lcount, ucount), | |
| extra = ucount - lcount) |> | |
| select(Ort, date, lcount, extra) | |
| vd <- dd |> | |
| pivot_longer(-c(Ort, date), | |
| names_to = "type", values_to = "count") |> | |
| mutate(type = ifelse(type == "extra", "max", "min")) |> | |
| group_by(type, date) |> | |
| summarize(n = sum(count)) | |
| vd |> | |
| ggplot(aes(date, n/100000, fill = type)) + | |
| geom_col() + | |
| scale_fill_manual(values = c(max = "grey", min = "black")) + | |
| labs(y = "Participants in 100,000s", | |
| x = "Date", | |
| fill = "Count range", | |
| title = "Anti-AfD Demo Participants (TAZ ranges)", | |
| subtitle = "Source: https://taz.de/Proteste-gegen-Rechtsextremismus/!5988174/") + | |
| theme_minimal() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment