Retrieves the variable structure of a PX-Web table, including available values and codelists. This is the key discovery step before fetching data.
Usage
get_variables(
api,
table_id,
cache = FALSE,
cache_location = pixieweb_cache_dir,
verbose = FALSE
)Arguments
- api
A
<px_api>object.- table_id
A single table ID (character).
- cache
Logical, cache results locally. When combined with a sqlite
cache_location(annxt_handlefrom nordstatExtras), the response is stored in the shared multi-process cache; otherwise a legacy.rdsfile is written underpixieweb_cache_dir().- cache_location
Either a path to a
.sqlitefile /nxt_handle, or a directory for legacy.rdscaching. Defaults topixieweb_cache_dir().- verbose
Print request details.
Examples
# \donttest{
scb <- px_api("scb", lang = "en")
if (px_available(scb)) {
get_variables(scb, "TAB638")
}# }
#> # A tibble: 6 × 8
#> code text n_values elimination time values codelists table_id
#> <chr> <chr> <int> <lgl> <lgl> <list> <list> <chr>
#> 1 Region region 312 TRUE FALSE <tibble> <tibble> TAB638
#> 2 Civilstand marital s… 4 TRUE FALSE <tibble> <NULL> TAB638
#> 3 Alder age 102 TRUE FALSE <tibble> <tibble> TAB638
#> 4 Kon sex 2 TRUE FALSE <tibble> <NULL> TAB638
#> 5 ContentsCode observati… 2 FALSE FALSE <tibble> <NULL> TAB638
#> 6 Tid year 57 FALSE TRUE <tibble> <NULL> TAB638