susr_tables.Rd
This function calls the SUSR open data API endpoint
https://data.statistics.sk/api/v2/collection?lang=en
to obtain a list
of all datasets, optionally filters them by domain/subdomain and/or
table code, and returns the results in a tibble.
susr_tables(long = FALSE, domains = NULL, table_codes = NULL, lang = "en")
Logical (default FALSE
). If TRUE
, the result is
"long" with one row per dimension code (see Details).
Character vector or NULL (default). If provided, we filter
tables to only those whose domain
OR subdomain
matches
any of these values. Domain info is taken from the static CSV loaded via
susr_domains()
.
Character vector or NULL (default). If provided, we filter to only these table codes.
The language code. Defaults to "en"
. Can also be "sk"
.
A tibble. The columns differ slightly depending on long
(wide vs. long).
Always contains: class
, href
, table_code
, label
, update
If long = FALSE
: also dimension_names
If long = TRUE
: also dimension_code
If domains
was used, columns domain
/ subdomain
from susr_domains()
are also included.
If long = FALSE
(default), each row corresponds to a single dataset
and the dimension codes are concatenated in the dimension_names
column,
separated by ":"
.
If long = TRUE
, the function pivots such that each dimension code is
in its own row (under dimension_code
).
If domains
is not NULL, this function calls susr_domains()
to retrieve
your static CSV with domain and subdomain data, joins it on table_code
,
and filters accordingly.
If table_codes
is not NULL, we filter the final list to only those codes.
if (FALSE) { # \dontrun{
# 1) Get all tables (wide format, no filtering)
tables_all <- susr_tables()
# 2) Filter to just certain table codes:
tables_some <- susr_tables(table_codes = c("as1001rs", "as1002rs"))
# 3) Filter by domain or subdomain:
env_tables <- susr_tables(domains = "Environment")
# 4) Combined: filter by domain + get long format
macroeconomic_tables <- susr_tables(long = TRUE, domains = "Macroeconomic statistics")
} # }