Given a data frame containing multiple surveys (one row per survey), transforms the data into long format with one row per party.
collapse_parties(
surveys,
parties = c("cdu", "spd", "greens", "fdp", "left", "pirates", "fw", "afd", "bsw",
"others")
)Data frame in long format
# \donttest{
emnid <- scrape_wahlrecht()
#> 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.
emnid.long <- collapse_parties(emnid)
# }