fedstat_data_load_with_filters: (Deprecated) Download indicator data from fedstat.ru in one...

View source: R/fedstat_data_load_with_filters.R

fedstat_data_load_with_filtersR Documentation

(Deprecated) Download indicator data from fedstat.ru in one request

Description

Deprecated: use fedstat_download() and fedstat_collect(). This function sends the whole selection to Fedstat as one request, with no pauses or saved progress. Large selections are slow, often fail and put heavy load on Fedstat. It is kept so that existing scripts keep working. Replace data <- fedstat_data_load_with_filters("31074", filters = filters) with job <- fedstat_download("31074", filters = filters) and data <- fedstat_collect(job).

Size is the number of filter combinations: the product of the number of selected values of every filter. Up to 50,000 combinations, a deprecation message is shown once per session. Above 50,000, every call warns. Above 100,000, the function stops unless allow_large_requests = TRUE, and above 250,000 it always stops: such requests load Fedstat for all its users and rarely succeed.

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:

  1. asterix (*), alias for "select all possible filter values for this filter field"

All filter fields with more than one possible value must be explicitly specified in filters. Use "*" to select all values. Unspecified multi-value filters will produce an error.

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

Usage

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,
  allow_large_requests = FALSE
)

Arguments

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 filter_field_title1 could be a string "Year" with filter_value_title1 equal to 2020 and filter_field_title2 could be a string "OKATO" with filter_value_title1 equal to "Russian Federation" Not actual filter field titles and filter values titles because of ASCII requirement for CRAN

timeout_seconds

numeric, maximum time before a new GET and POST request is tried

retry_max_times

numeric, maximum pipeline attempts, including the first. Only transient failures and one session repair are retried. Filter metadata are retained after a successful GET; retries do not nest.

disable_warnings

bool, enables or disables warnings about non matched filter_value_title in filters and filter_value_title from data_ids.

httr_verbose

httr::verbose() or NULL, outputs messages to the console about the processing of the request

loading_steps_verbose

logical, print data loading steps to console

return_type

character, "data" or "dictionary", data for actual data, dictionary for sdmx lookup table (full data codes dictionary). fedstat_dictionary() gets the dictionary without choosing filters.

try_to_parse_ObsValue

logical, try to parse ObsValue column from character to R numeric type

allow_large_requests

logical. TRUE allows selections of up to 250,000 filter combinations instead of 100,000. Larger selections are always refused; use fedstat_download() for them.

Value

data.frame with filtered indicator data from fedstat.ru

See Also

fedstat_download, fedstat_get_data_ids, fedstat_data_ids_filter, fedstat_post_data_ids_filtered, fedstat_parse_sdmx_to_table

Examples

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

fedstatAPIr documentation built on Nov. 4, 2026, 9:07 a.m.