Skip to contents

Determines political level(s) of one or more variables.

Usage

var_lvls(var_names)

Arguments

var_names

A character vector of FOKUS variable names.

Value

A character vector of political levels, of length 0 if no specific levels could be determined.

Details

Note that the political levels are determined by simply parsing var_names.

Examples

fokus::qstnrs |>
  dplyr::mutate(lvls = purrr::map(variable_name,
                                  fokus::var_lvls)) |>
  dplyr::filter(purrr::map_lgl(lvls,
                               \(x) length(x) > 0)) |>
  dplyr::select(variable_name, lvls) |>
  tidyr::unnest_longer(col = lvls,
                       values_to = "lvl") |>
  unique()
#> # A tibble: 374 × 2
#>    variable_name                       lvl     
#>    <chr>                               <chr>   
#>  1 cantonal_attachment                 cantonal
#>  2 political_interest_cantonal         cantonal
#>  3 voting_decision_federal_proposal_1  federal 
#>  4 voting_decision_federal_proposal_2  federal 
#>  5 voting_decision_federal_proposal_3  federal 
#>  6 voting_decision_cantonal_proposal_1 cantonal
#>  7 importance_cantonal_proposal_1      cantonal
#>  8 affectedness_cantonal_proposal_1    cantonal
#>  9 main_motive_cantonal_proposal_1_yes cantonal
#> 10 main_motive_cantonal_proposal_1_no  cantonal
#> # ℹ 364 more rows