Skip to contents

Executes an nso_query and returns a tidy tibble with one column per dimension and a numeric value column. Use labels to add _en/_mn columns for each dimension.

Usage

nso_fetch(
  x,
  labels = c("code", "en", "mn", "both"),
  value_name = getOption("mongolstats.value_name", "value"),
  include_raw = getOption("mongolstats.attach_raw", FALSE)
)

Arguments

x

An nso_query object.

labels

One of "code", "en", "mn", or "both". "none" is accepted as an alias for "code" (matching nso_data()). Defaults to the mongolstats.default_labels option, like nso_data().

value_name

Name of the numeric value column in the result (default: "value").

include_raw

If TRUE, attach the raw PX payload as attribute px_raw.

Value

A tibble.

Examples

q <- nso_query("DT_NSO_0300_001V2", list(Year = "2023"))
data <- nso_fetch(q)
head(data)
#> # A tibble: 6 × 4
#>   Sex   Age   Year    value
#>   <chr> <chr> <chr>   <dbl>
#> 1 0     0     2     3404028
#> 2 0     1     2       65418
#> 3 0     2     2       65653
#> 4 0     3     2       71885
#> 5 0     4     2       76194
#> 6 0     5     2       78627