Returns sub-topics or datasets tagged directly to a given topic. Use
statswales_list_topics() to discover topic IDs.
Usage
statswales_get_topic(
topic_id,
lang = "en-gb",
page_number = 1,
page_size = 100,
sort_by = NULL
)Arguments
- topic_id
A numeric topic ID. Use
statswales_list_topics()to find IDs.- lang
Language for returned text. One of
"en-gb"(default),"en","cy-gb", or"cy".- page_number
Page number to return. Default
1.- page_size
Number of results per page. Default
100.- sort_by
Optional sort order for datasets under a leaf topic. Either a string in
"column:direction"format (e.g."title:asc") or a named character vector such asc(title = "asc", last_updated_at = "desc").
Value
A list with fields selectedTopic, children, parents, and
datasets. Returns NULL if the request fails.
Details
The returned list has four fields:
selectedTopicDetails of the requested topic.
childrenSub-topics under this topic. Empty for leaf topics.
parentsAncestor topics from root to the selected topic.
datasetsA list with
data(dataset list items) andcount. Only populated for leaf topics (those with nochildren).
Examples
if (FALSE) { # \dontrun{
topics <- statswales_list_topics()
topic <- statswales_get_topic(topics$id[1])
# Sub-topics (non-leaf)
topic$children
# Datasets at a leaf topic
topic$datasets$data
topic$datasets$count
} # }