Skip to contents

Returns the labels of the latest periods published in a table, ready to use in selections. Combine with nso_data() to keep a script on the newest data without hard-coding years.

Usage

nso_latest_periods(tbl_id, n = 1)

Arguments

tbl_id

Table identifier.

n

Number of periods to return.

Value

A character vector of up to n period labels, oldest first; empty in offline mode (see nso_offline_enable()).

See also

nso_table_periods() for every period with its date.

Examples

if (FALSE) { # identical(Sys.getenv("NOT_CRAN"), "true") && curl::has_internet()
nso_latest_periods("DT_NSO_0300_001V2", n = 3)

# Fetch the latest year without hard-coding it
nso_data(
  "DT_NSO_0300_001V2",
  list(Year = nso_latest_periods("DT_NSO_0300_001V2"), Sex = "Total", Age = "Total")
)
}