list_sudd_rfrnds: List referendum data from sudd.ch

list_sudd_rfrndsR Documentation

List referendum data from sudd.ch

Description

Lists the referendum data from sudd.ch in various ways its list.php endpoint allows. The output of this function can be directly fed to sudd_rfrnds().

Usage

list_sudd_rfrnds(
  mode = c("by_date", "by_mod_date", "filter", "random"),
  order = c("ascending", "descending"),
  filter = list(territory_name_de = NULL, title_de = NULL, year_min = NULL, year_max =
    NULL),
  use_cache = TRUE,
  max_cache_age = "1 week",
  quiet = FALSE
)

Arguments

mode

The listing mode. One of

  • "by_date": Lists all referendums in the sudd.ch database by date, together with their id_sudd, country_code, territory_name_de and title_de. Specifying the sorting order of the results via the order parameter is supported.

  • "by_mod_date": Lists all referendums in the sudd.ch database by date_last_edited, together with their id_sudd, country_code, territory_name_de, date and title_de.

  • "filter": Allows to provide additional arguments (via the filter parameter) that limit the results accordingly. Specifying the sorting order of the results via the order parameter is supported.

  • "random": Lists the id_sudd of five randomly selected referendums, together with their country_code.

order

The sorting order of the results. Only relevant if mode is either "by_date" or "filter".

filter

A list with valid filtering arguments. Only relevant if mode = "filter". The supported filtering arguments include

  • territory_name_de: A string that must be (partially) matched by the referendums' territory_name_de. Matching is case-insensitive and no fuzzy matching is supported.

  • title_de: A string that must be (partially) matched by the referendums' title_de. Matching is case-insensitive and no fuzzy matching is supported.

  • year_min: The lower year limit of the referendums' date. A positive integer.

  • year_max: The upper year limit of the referendums' date. A positive integer.

use_cache

Whether or not to return cached results if possible. If FALSE, results are always newly fetched regardless of max_cache_age.

max_cache_age

Duration after which cached results are refreshed (i.e. newly fetched). A valid lubridate duration. Use Inf to disable cache expiry. Only relevant if use_cache = TRUE.

quiet

Whether or not to suppress printing status output from internal processing.

Value

A tibble containing at least an id_sudd column.

About sudd.ch

sudd stands for Suchmaschine für direkte Demokratie (German) and is operated by Beat Müller. Its database content is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0).

See Also

Other sudd.ch scraping functions: list_sudd_territories(), list_sudd_titles(), sudd_rfrnds()

Examples

# list all referendums by modification date (takes a while)
## Not run: 
rdb::list_sudd_rfrnds(mode = "by_mod_date")
## End(Not run)

# list all referendums whose title matches "AHV"
rdb::list_sudd_rfrnds(mode = "filter",
                      filter = list(title_de = "AHV"),
                      quiet = TRUE)

# get sudd.ch referendum data from all referendums from 2020 onwards
rdb::list_sudd_rfrnds(mode = "filter",
                      filter = list(year_min = 2020),
                      quiet = TRUE) |>
  rdb::sudd_rfrnds(quiet = TRUE)

# get sudd.ch referendum data from five randomly picked referendums
rdb::list_sudd_rfrnds(mode = "random",
                      quiet = TRUE) |>
  rdb::sudd_rfrnds(quiet = TRUE)

zdaarau/c2d documentation built on Dec. 18, 2024, 1:24 p.m.