Reads in the FOKUS survey dataset generated by export_survey_data()
for the specified ballot date in the specified canton and language, optionally merged
with all prior survey datasets for that canton and language.
Usage
read_survey_data(
ballot_date = pal::pkg_config_val("ballot_date"),
canton = cantons(ballot_date),
lang = pal::pkg_config_val("lang"),
merged = FALSE,
use_cache = TRUE,
auth_token = pal::pkg_config_val("token_repo_private")
)
Arguments
- 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"
.- merged
Whether or not to read in the merged dataset that includes the data from all ballot dates up until
ballot_date
that were covered by FOKUS surveys in the specifiedcanton
. See section Merged data below for details. IfFALSE
, only the data forballot_date
itself is returned.- use_cache
Whether or not to return cached results if possible. Caching is done based on file content hashing, so the file is only newly fetched if it actually changed since the last download. If
FALSE
, the file is always newly fetched.- auth_token
Personal access token of a gitlab.com account with access to the private FOKUS repository.
Value
A tibble.
Merged data
Merged datasets differ from single-ballot-date datasets in two ways:
Column labels (the
label
attribute) are ballot-date-independent, i.e. do not include proposal or election names, and in case of question rewordings over time, the very latest question wording of all FOKUS surveys in that canton is used (which might have been introduced only afterballot_date
). So be aware that the questions in the labels do not necessarily correspond to the actual questions asked in the FOKUS survey forballot_date
.Variables whose factor levels vary across ballot dates, such as those capturing skill questions, are converted to type character. Be aware that these variables usually aren't really comparable over time.
See also
Other data import functions:
read_easyvote_municipalities()
,
read_online_participation_codes()
,
read_private_file()
,
read_voting_register_data_extra()
,
read_voting_register_ids()
,
tidy_cols()
Examples
# GitLab PAT with access to the private FOKUS repository is required for this function to work
try(
fokus::read_survey_data(ballot_date = "2023-06-18",
canton = "aargau",
lang = "en") |>
nrow()
)
#> [1] 2309
try(
fokus::read_survey_data(ballot_date = "2023-06-18",
canton = "aargau",
lang = "en",
merged = TRUE) |>
nrow()
)
#> [1] 12506