Scrapes survey tables and performs sanitation to output tidy data
scrape_wahlrecht(
address = "https://www.wahlrecht.de/umfragen/emnid.htm",
parties = c("CDU", "SPD", "GRUENE", "FDP", "LINKE", "PIRATEN", "AFD", "BSW",
"SONSTIGE")
)
scrape_by(
address = "https://www.wahlrecht.de/umfragen/landtage/bayern.htm",
parties = c("CSU", "SPD", "GRUENE", "FDP", "LINKE", "PIRATEN", "FW", "AFD", "SONSTIGE")
)
scrape_rp(
address = "https://www.wahlrecht.de/umfragen/landtage/rheinland-pfalz.htm",
parties = c("CDU", "SPD", "GRUENE", "FDP", "LINKE", "AFD", "FW", "SONSTIGE"),
ind_row_remove = -c(1:3)
)
scrape_ltw(
address = "https://www.wahlrecht.de/umfragen/landtage/niedersachsen.htm",
parties = c("CDU", "SPD", "GRUENE", "FDP", "LINKE", "PIRATEN", "FW", "AFD", "BSW",
"SONSTIGE"),
ind_row_remove = -c(1:2)
)A tibble with one row per survey date and columns for date, respondents, and one column per party containing the percentage of votes.
# \donttest{
library(coalitions)
library(dplyr)
scrape_wahlrecht() %>% slice(1:5)
#> Warning: There were 7 warnings in `mutate()`.
#> The first warning was:
#> ℹ In argument: `across(all_of(parties), extract_num)`.
#> Caused by warning:
#> ! NAs introduced by coercion
#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 6 remaining warnings.
#> Warning: There was 1 warning in `mutate()`.
#> ℹ In argument: `datum = dmy(.data$datum)`.
#> Caused by warning:
#> ! 1 failed to parse.
#> # A tibble: 5 × 12
#> date start end cdu spd greens fdp left afd bsw
#> <date> <date> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 2013-09-29 2013-09-24 2013-09-26 43 26 7 3 9 6 NA
#> 2 2013-10-06 2013-09-26 2013-10-01 42 25 8 4 9 6 NA
#> 3 2013-10-13 2013-10-04 2013-10-09 42 25 9 3 10 6 NA
#> 4 2013-10-20 2013-10-10 2013-10-16 42 25 9 3 10 5 NA
#> 5 2013-10-27 2013-10-17 2013-10-23 41 26 10 3 9 5 NA
#> # ℹ 2 more variables: others <dbl>, respondents <dbl>
# }
# \donttest{
# Niedersachsen
scrape_ltw() %>% slice(1:5)
#> # A tibble: 5 × 12
#> pollster date start end cdu spd greens fdp left afd
#> <chr> <date> <date> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 insa 2026-04-22 2026-04-22 2026-04-22 25 25 12 4 7 20
#> 2 allensb… 2026-02-25 2026-02-25 2026-02-25 27 26 10 3 7 21
#> 3 infrate… 2025-11-19 2025-11-19 2025-11-19 26 26 12 3 6 20
#> 4 insa 2025-02-19 2025-02-19 2025-02-19 30 25 10 5 5 16
#> 5 allensb… 2024-12-05 2024-12-05 2024-12-05 33 27 10 4 NA 16
#> # ℹ 2 more variables: others <dbl>, respondents <dbl>
# Hessen
scrape_ltw("https://www.wahlrecht.de/umfragen/landtage/hessen.htm", ind_row_remove=-c(1)) %>%
slice(1:5)
#> # A tibble: 5 × 13
#> pollster date start end cdu spd greens fdp left afd
#> <chr> <date> <date> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 insa 2026-04-29 2026-04-29 2026-04-29 30 15 13 3 7 22
#> 2 insa 2026-03-18 2026-03-18 2026-03-18 31 15 13 4 6 21
#> 3 infrate… 2026-02-02 2026-02-02 2026-02-02 32 16 14 3 6 20
#> 4 insa 2025-10-09 2025-10-09 2025-10-09 32 15 12 4 7 20
#> 5 infrate… 2025-06-23 2025-06-23 2025-06-23 36 13 14 4 6 18
#> # ℹ 3 more variables: fw <dbl>, others <dbl>, respondents <dbl>
# }