canton_json_to_dfr tranforms a single results json for a selected cantonal votedate into a tibble.

canton_json_to_dfr(
  votedate = NULL,
  geolevel = "municipality",
  dataurl = NULL,
  index = NULL,
  call_res
)

Arguments

votedate

date of the ballot. Default: most recent ballot available.

geolevel

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

dataurl

list of datasets / metadata for the given dataset and its resources OR url of the dcat dataset on opendata.swiss

index

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

call_res

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

Value

a tibble containing the results

Examples

# Get and transform the json for the most recent vote results <- canton_json_to_dfr() # Get and transform the json for a single votedate at counting district level canton_json_to_dfr(votedate = "2020-02-09", geolevel = "zh_counting_districts")
#> # A tibble: 2,829 × 18 #> id canton_name mun_id mun_name geoLevelParentn… gebietAusgezaeh… #> <int> <chr> <chr> <chr> <chr> <lgl> #> 1 104947 ZH 1 Aeugst am Albis 101 TRUE #> 2 104947 ZH 2 Affoltern am Albis 101 TRUE #> 3 104947 ZH 3 Bonstetten 101 TRUE #> 4 104947 ZH 4 Hausen am Albis 101 TRUE #> 5 104947 ZH 5 Hedingen 101 TRUE #> 6 104947 ZH 6 Kappel am Albis 101 TRUE #> 7 104947 ZH 7 Knonau 101 TRUE #> 8 104947 ZH 8 Maschwanden 101 TRUE #> 9 104947 ZH 9 Mettmenstetten 101 TRUE #> 10 104947 ZH 10 Obfelden 101 TRUE #> # … with 2,819 more rows, and 12 more variables: jaStimmenInProzent <dbl>, #> # jaStimmenAbsolut <int>, neinStimmenAbsolut <int>, #> # stimmbeteiligungInProzent <dbl>, eingelegteStimmzettel <int>, #> # anzahlStimmberechtigte <int>, gueltigeStimmen <int>, de <chr>, fr <chr>, #> # it <chr>, rm <chr>, votedate <date>