oecdDataset: Resolve an OECD Dataset to a Canonical Reference

View source: R/dataset.R

oecdDatasetR Documentation

Resolve an OECD Dataset to a Canonical Reference

Description

Resolve a readable dataset code, optional identity selectors and its structure version without downloading observations.

Usage

oecdDataset(OECDDatasetCode, agency = NULL, prefix = NULL, version = NULL)

Arguments

OECDDatasetCode

A short code, a complete dataflow ID, or a reference "AGENCY,DATAFLOW[,VERSION]". For example "CLI", "DF_CLI", "DSD_STES@DF_CLI", or "OECD.SDD.STES,DSD_STES@DF_CLI".

agency

Optional single agency identifier, for example "OECD.SDD.STES".

prefix

Optional dataflow namespace prefix before @, for example "DSD_STES". This selects the prefix of the dataflow identifier; the actual referenced data structure is still resolved from the returned metadata.

version

Optional numeric version string, "latest", or "+". An omitted version selects the catalogue's current stable version. An explicit older version is requested even when the current catalogue lists a newer one; the service must still supply metadata for that older version.

Details

This is a package-level convenience, not a different OECD API. For unqualified input, matching is case-insensitive and follows three levels: complete dataflow ID, terminal ID after the last @, then that terminal ID with a leading DF_ removed. The first non-empty level is used. No fuzzy matching, legacy-code translation or hard-coded alias table is used.

Selectors restrict the catalogue before matching. If the chosen level contains more than one agency/dataflow identity, an OECDdata_ambiguous error lists canonical candidates and carries their complete rows in candidates. Use the agency or prefix selector, or a canonical reference. Selectors that conflict with an explicitly qualified reference are errors, not overrides.

importDataList advertises a ShortCode only if it cannot collide with any other identity's literal, terminal or compact code. Otherwise that column is missing. A short code can become ambiguous after catalogue changes; store this function's canonical result for repeatable dataset selection.

A qualified reference bypasses the catalogue, but its structure is still fetched or read from a verified cache. Offline shorthand resolution needs a cached catalogue in addition to cached structure/data responses. This function fetches structure metadata and dictionaries, but never observations. Returned structure versions do not freeze future observation revisions.

importData and oecdQuery also accept these selectors in a reserved filters = list(.dataset = list(agency = ..., prefix = ..., version = ...), REF_AREA = ...) block. Dataset selectors are removed before building observation filters. A block containing only dataset selectors leaves all dimensions unrestricted. Metadata functions accept this function's returned reference.

Value

One character string containing the canonical, fully qualified "AGENCY,DATAFLOW,VERSION" reference with an exact resolved version.

See Also

importData, importDataList, oecdQuery, oecdStructure

Examples

if (interactive()) {
ref <- oecdDataset("CLI", agency = "OECD.SDD.STES", prefix = "DSD_STES")
s <- oecdStructure(ref)
importLabels(OECDDimCode = "REF_AREA", dataset = ref)
q <- oecdQuery("CLI", filters = list(
  .dataset = list(agency = "OECD.SDD.STES"),
  REF_AREA = "USA", FREQ = "M", TIME_PERIOD = c("2023-01", "2023-12")))
attr(q, "OECDDatasetCode")
}

OECDdata documentation built on Oct. 31, 2026, 1:07 a.m.