View source: R/fedstat_data_load_with_filters.R
fedstat_data_load_with_filters | R Documentation |
This function is a wrapper for the other functions of the package to provide a simple one function API for fedstat.ru
There are two basic terms in this API: filter_field
and filter_value
The filter field
reflects the individual property of the data point.
For example, Year, Region, Unit of measurement, etc.
Each filter field has its own title (filter_field_title
),
it is simply a human-readable word or phrase (e.g. "Year", "Region")
that reflects the essence of the property by which filtering takes place
The filter value
reflects the individual property specific value of the data point.
(e.g. 2021 for the Year, "Russian Federation" for the region, etc.)
It also has a title (filter_value_title
) with
the same purpose as filter_field_title
filters
should use filter_field_title
in names and filter_value_title
in values as
they are presented on fedstat.ru. If for some reason the specified filters
do not return the expected result, it is worth using
fedstat_get_data_ids
separately and inspecting possible
filter values in data_ids
to see if the strings are defined correctly
(e.g. encoding issues, mixing latin and cyrillic symbols)
filter_value_title
currently supports the following special values:
asterix (*), alias for "select all possible filter values for this filter field"
Unspecified filters use asterix as a default (i.e. all possible filter values are selected and a warning is given)
Internally normalized filter_field_title
and filter_value_title
are
used (all lowercase, removed extra whitespaces)
to compare the equality of data_ids
and filters
fedstat_data_load_with_filters(
indicator_id,
...,
filters = list(),
timeout_seconds = 180,
retry_max_times = 3,
disable_warnings = FALSE,
httr_verbose = NULL,
loading_steps_verbose = TRUE,
return_type = c("data", "dictionary"),
try_to_parse_ObsValue = TRUE
)
indicator_id |
character, indicator id/code from indicator URL. For example for indicator with URL https://www.fedstat.ru/indicator/37426 indicator id will be 37426 |
... |
other arguments passed to httr::GET and httr::POST |
filters |
JSON in R list form. The structure should be like this: { "filter_field_title1": ["filter_value_title1", "filter_value_title2"], "filter_field_title2": ["filter_value_title1", "filter_value_title2"], ... } Where for example |
timeout_seconds |
numeric, maximum time before a new GET and POST request is tried |
retry_max_times |
numeric, maximum number of tries to GET and POST |
disable_warnings |
bool, enables or disables following warnings:
|
httr_verbose |
|
loading_steps_verbose |
logical, print data loading steps to console |
return_type |
character, "data" or "dicionary", data for actual data, dictionary for sdmx lookup table (full data codes dictionary) |
try_to_parse_ObsValue |
logical, try to parse ObsValue column from character to R numeric type |
data.frame with filtered indicator data from fedstat.ru
fedstat_get_data_ids,
fedstat_data_ids_filter,
fedstat_post_data_ids_filtered,
fedstat_parse_sdmx_to_table
## Not run:
# Download CPI data
# for all goods and services for Russian Federation
data <- fedstat_data_load_with_filters(
indicator_id = "31074",
filters = list(
"Territory" = "Russian Federation",
"Year" = "2023",
"Period" = "January",
"Types of goods and services" = "*"
)
)
# Not actual filter field titles and filter values titles because of ASCII requirement for CRAN
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.