Downloads the referendum data from the Referendum Database (RDB). See the codebook
for a detailed description of all variables.
Usage
rfrnds_old(
country_code = NULL,
subnational_entity_name = NULL,
municipality = NULL,
level = NULL,
type = NULL,
date_min = NULL,
date_max = NULL,
is_draft = FALSE,
date_time_created_min = NULL,
date_time_created_max = NULL,
date_time_last_edited_min = NULL,
date_time_last_edited_max = NULL,
query_filter = NULL,
incl_archive = FALSE,
tidy = TRUE,
use_cache = TRUE,
max_cache_age = "1 week",
use_testing_server = pal::pkg_config_val(key = "use_testing_server", pkg = this_pkg),
quiet = FALSE
)
Arguments
- country_code
The
country_code
(s) to be included. A character vector.- subnational_entity_name
The
subnational_entity_name
(s) to be included. A character vector.- municipality
The
municipality
(s) to be included. A character vector.- level
The
level
(s) to be included. A character vector.- type
The
type
(s) to be included. A character vector.- date_min
The minimum
date
to be included. A date or something coercible to.- date_max
The maximum
date
to be included. A date or something coercible to.- is_draft
TRUE
means to include only referendum entries with draft status,FALSE
to include only normal entries. Set toNULL
in order to include both draft and normal entries.- date_time_created_min
The minimum
date_time_created
to be included. A datetime, or something coercible to (like"2006-01-02"
or"2006-01-02T15:04:05Z"
; assumed to be in UTC if no timezone is given).- date_time_created_max
The maximum
date_time_created
to be included. A datetime, or something coercible to (like"2006-01-02"
or"2006-01-02T15:04:05Z"
; assumed to be in UTC if no timezone is given).- date_time_last_edited_min
The minimum
date_time_last_edited
to be included. A datetime, or something coercible to (like"2006-01-02"
or"2006-01-02T15:04:05Z"
; assumed to be in UTC if no timezone is given).- date_time_last_edited_max
The maximum
date_time_last_edited
to be included. A datetime, or something coercible to (like"2006-01-02"
or"2006-01-02T15:04:05Z"
; assumed to be in UTC if no timezone is given).- query_filter
A valid MongoDB JSON query filter document which allows for maximum control over what data is included. This takes precedence over all of the above listed parameters, i.e. if
query_filter
is provided, the parameterscountry_code
,subnational_entity_name
,municipality
,level
,type
,date_min
,date_max
,is_draft
,date_time_created_min
,date_time_created_max
,date_time_last_edited_min
anddate_time_last_edited_max
are ignored.- incl_archive
Whether or not to include an
archive
column containing data from an earlier, obsolete state of the Referendum Database (RDB).- tidy
Whether or not to tidy the referendum data, i.e. apply various data cleansing tasks and add additional variables. If
FALSE
, the raw MongoDB referendum data will only be modified just enough to be able to return it as a tibble. Note that untidy data doesn't conform to the codebook (i.a. different variable names).- use_cache
Whether or not to return cached results if possible. If
FALSE
, results are always newly fetched regardless ofmax_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 ifuse_cache = TRUE
.- use_testing_server
Whether or not to use the testing servers instead of the production servers for RDB Services API calls etc.
- quiet
Whether or not to suppress printing status output from internal processing.
Value
A tibble.
See also
Other referendum data functions:
add_rfrnds()
,
assert_vars()
,
count_rfrnds()
,
delete_rfrnds()
,
download_file_attachment()
,
edit_rfrnds()
,
rfrnd()
,
rfrnd_exists()
,
rfrnds()
,
search_rfrnds()
,
validate_rfrnds()
Examples
if (FALSE) { # \dontrun{
# get all referendums (excl. drafts)
rdb::rfrnds_old()
# get only referendums in Austria and Australia on subnational level
rdb::rfrnds_old(country_code = c("AT", "AU"),
level = "subnational",
quiet = TRUE)
# get referendums in 2020
rdb::rfrnds_old(date_min = "2020-01-01",
date_max = "2020-12-31",
quiet = TRUE)
# get referendums added to the database during the last 30 days
rdb::rfrnds_old(date_time_created_min = clock::date_today(zone = "UTC") |> clock::add_days(-30L),
date_time_created_max = clock::date_today(zone = "UTC"),
quiet = TRUE)
# provide custom `query_filter` for more complex queries like regex matches
# cf. https://docs.mongodb.com/manual/reference/operator/query/regex/
rdb::rfrnds_old(query_filter = '{"country_code":{"$regex":"A."}}',
quiet = TRUE)} # }