Skip to contents

Determines the election number each variable corresponds to. In case no election number could be determined for a variable, NA_character is returned.

Usage

var_election_nr(var_names)

Arguments

var_names

A character vector of FOKUS variable names.

Value

An integer vector of the same length as var_names.

Details

Note that the determination is performed by simply parsing var_names.

See also

Examples

fokus::qstnrs |>
  dplyr::mutate(election_nr = fokus::var_election_nr(variable_name)) |>
  dplyr::filter(!is.na(election_nr)) |>
  dplyr::select(variable_name, election_nr) |>
  unique()
#> # A tibble: 91 × 2
#>    variable_name                                                        election_nr
#>    <chr>                                                                      <int>
#>  1 hypothetical_voting_decision_federal_proportional_election_1_party             1
#>  2 hypothetical_voting_decision_federal_majoritarian_election_1_seat_1            1
#>  3 hypothetical_voting_decision_federal_majoritarian_election_1_seat_2            1
#>  4 hypothetical_voting_decision_cantonal_majoritarian_election_1_seat_1           1
#>  5 voting_decision_past_federal_proportional_election_1_party                     1
#>  6 voting_decision_federal_proportional_election_1_party                          1
#>  7 voting_decision_federal_proportional_election_1_ticket                         1
#>  8 ticket_modification_federal_proportional_election_1                            1
#>  9 ticket_modification_federal_proportional_election_1_cumulated                  1
#> 10 ticket_modification_federal_proportional_election_1_delisted                   1
#> # ℹ 81 more rows