Skip to contents

Extracts a variable's value set from the questionnaire data in the specified language (or its integer representation if lang = "int").

Usage

var_val_set(
  var_name,
  ballot_date = pal::pkg_config_val("ballot_date"),
  canton = cantons(ballot_date),
  lang = pal::pkg_config_val("lang")
)

Arguments

var_name

Variable name. A character scalar.

ballot_date

FOKUS-covered ballot date. One of

  • "2018-09-23"

  • "2018-11-25"

  • "2019-10-20"

  • "2020-09-27"

  • "2020-10-18"

  • "2021-11-28"

  • "2023-06-18"

  • "2024-10-20"

canton

FOKUS-covered canton name. One of

  • "aargau"

lang

Language. One of "de", "en" or "int" for the value set's integer codes."

Value

A character scalar.

See also

Examples

fokus::var_val_set(var_name = "favored_party",
                   ballot_date = "2018-09-23",
                   canton = "aargau")
#>  [1] "SVP"                                    "SP"                                     "FDP"                                   
#>  [4] "CVP"                                    "Grüne"                                  "GLP"                                   
#>  [7] "EVP"                                    "BDP"                                    "eine andere, nämlich: ✍ (Freitextfeld)"
#> [10] "keine"                                  "weiss nicht"                           

fokus::var_val_set(var_name = "favored_party",
                   ballot_date = "2023-06-18",
                   canton = "aargau")
#>  [1] "SVP"                                    "SP"                                     "FDP"                                   
#>  [4] "Mitte"                                  "Grüne"                                  "GLP"                                   
#>  [7] "EVP"                                    "eine andere, nämlich: ✍ (Freitextfeld)" "keine"                                 
#> [10] "weiss nicht"                           

fokus::var_val_set(var_name = "favored_party",
                   ballot_date = "2023-06-18",
                   canton = "aargau",
                   lang = "en")
#>  [1] "SVP"           "SP"            "FDP"           "Mitte"         "Grüne"         "GLP"           "EVP"           "custom answer" "none"         
#> [10] "don't know"   

fokus::var_val_set(var_name = "favored_party",
                   ballot_date = "2023-06-18",
                   canton = "aargau",
                   lang = "int")
#>  [1]  1  2  3  9  5  6  7 90  0 99