Retrieves the complete structure of a statistical classification published in either CELLAR or FAO repositories based on a Prefix–ConceptScheme pair obtained using classificationList().

The resulting table is suitable for classification browsing, integrity checks, hierarchical analysis, documentation, and downstream correspondence mapping.

retrieveClassificationTable(
  endpoint,
  prefix,
  conceptScheme,
  language = "en",
  level = "ALL",
  showQuery = FALSE,
  knownSchemes = NULL,
  preferMappingOnly = FALSE
)

Arguments

endpoint

Character. Repository to query. Must be either "CELLAR" or "FAO".

prefix

Character. Classification prefix used for matching and URI resolution (e.g. "cn2022", "cpc21", "isic4").

conceptScheme

Character. Local identifier of the scheme (often identical to prefix). The function automatically resolves this to the canonical ConceptScheme URI published in the endpoint.

language

Character. Desired language for labels, scope notes and exclusion notes. Default: "en".

level

Character. One of:

  • "ALL" (default): return all levels in the hierarchy;

  • a specific depth value (e.g. "2") to filter concepts at that depth only.

showQuery

Logical.

  • FALSE (default): returns only the classification table;

  • TRUE: returns a list containing the SPARQL query, the resolved scheme URI, and the table itself.

knownSchemes

Optional. A data.frame supplying authoritative mappings of the form Prefix, ConceptScheme, URI[, Endpoint]. When provided, this overrides automatic discovery. To be obtained using classificationList(endpoint).

preferMappingOnly

Logical. If TRUE, the function never attempts SPARQL discovery and uses only information in knownSchemes or classificationList(endpoint). Default: FALSE.

Value

If showQuery = FALSE, a data.frame with one row per concept and columns:

  • Concept: full concept URI;

  • Code: skos:notation coerced to string;

  • Label: preferred or alternative label in the requested language;

  • Depth: xkos:depth if available;

  • BroaderList: broader concept URIs (pipe-separated);

  • BroaderCodeList: broader concept notations (pipe-separated);

  • IncludeNotes: skos:scopeNote values (double-pipe-separated);

  • ExcludeNotes: xkos:exclusionNote values (double-pipe-separated).

If showQuery = TRUE, returns a list with:

  • SPARQL.query – the executed SPARQL string;

  • scheme_uri – the resolved ConceptScheme URI;

  • ClassificationTable – the data.frame described above.

Examples

if (FALSE) { # \dontrun{
# Retrieve full CN2022 classification (English)
cn <- retrieveClassificationTable(
  endpoint      = "CELLAR",
  prefix        = "cn2022",
  conceptScheme = "cn2022",
  language      = "en"
)

# Retrieve CPC v2.1 from FAO and inspect query
out <- retrieveClassificationTable(
  endpoint      = "FAO",
  prefix        = "cpc21",
  conceptScheme = "cpc21",
  showQuery     = TRUE
)
cat(out$SPARQL.query)
} # }