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")
)

Arguments

surveys

A data frame with one survey per row.

parties

A character vector containing names of parties to collapse.

Value

Data frame in long format

Examples

# \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)
# }