canton_json_to_dfr: Transform a opendata.swiss cantonal results json into a...

View source: R/canton_json_to_dfr.R

canton_json_to_dfrR Documentation

Transform a opendata.swiss cantonal results json into a tibble

Description

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

Usage

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")


politanch/swissdd documentation built on June 12, 2025, 6:42 a.m.