swiss_json_to_dfr transforms the json containing the results of a selected federal votedate into a tibble.

swiss_json_to_dfr(
  votedate = NULL,
  geolevel = "municipality",
  dataurl = NULL,
  index = NULL,
  language = "DE",
  call_res
)

Arguments

votedate

date of the ballot. Default: most recent ballot available. To select multiple ballots use the 'get_swissvotes'-function. Format = YYYYMMDD

geolevel

geographical level for which the results should be loaded. Options: "national", "canton", "district" or "municipality".

dataurl

url of the dataset on opendata.swiss

index

selection by index of the resource (last published = 1).

language

defines the language of the vote title. Options: "DE" for German, "FR" for French, "IT" for Italian or "RM" for Romansh.

call_res

result of a previous call to the base API. Optional argument.

Value

a tibble containing the results

Examples

# Transform the json of the most recent vote results <- swiss_json_to_dfr() # Transform the json of a selected votedate swiss_json_to_dfr(votedate = "2019-02-10")
#> # A tibble: 2,152 × 16 #> name id canton_id canton_name mun_id mun_name geoLevelParentn… #> <chr> <int> <chr> <chr> <chr> <chr> <chr> #> 1 Volksinitiativ… 6260 1 Zürich 1 Aeugst a… 101 #> 2 Volksinitiativ… 6260 1 Zürich 2 Affolter… 101 #> 3 Volksinitiativ… 6260 1 Zürich 3 Bonstett… 101 #> 4 Volksinitiativ… 6260 1 Zürich 4 Hausen a… 101 #> 5 Volksinitiativ… 6260 1 Zürich 5 Hedingen 101 #> 6 Volksinitiativ… 6260 1 Zürich 6 Kappel a… 101 #> 7 Volksinitiativ… 6260 1 Zürich 7 Knonau 101 #> 8 Volksinitiativ… 6260 1 Zürich 8 Maschwan… 101 #> 9 Volksinitiativ… 6260 1 Zürich 9 Mettmens… 101 #> 10 Volksinitiativ… 6260 1 Zürich 10 Obfelden 101 #> # … with 2,142 more rows, and 9 more variables: gebietAusgezaehlt <lgl>, #> # jaStimmenInProzent <dbl>, jaStimmenAbsolut <int>, neinStimmenAbsolut <int>, #> # stimmbeteiligungInProzent <dbl>, eingelegteStimmzettel <int>, #> # anzahlStimmberechtigte <int>, gueltigeStimmen <int>, votedate <date>