Used to get details about codes and code lists stored by ONS. Codes are used to provide a common definition when presenting statistics with related categories. Codes are gathered in code lists, which may change over time to include new or different codes. The meaning of a code should not change over time, but new codes may be created where new meaning is required.

ons_codes(code_id = NULL, edition = NULL)

ons_code(code_id = NULL, edition = NULL, code = NULL)

ons_code_dataset(code_id = NULL, edition = NULL, code = NULL)

Arguments

code_id

[character]. The id of a codelist.

edition

[character] A subset of the dataset representing a specific time period. For some datasets this edition can contain all time periods (all historical data). The latest version of this is displayed by default.

code

[character] The ID of the code within a code list.

Value

A list or character vector.

Examples


# \donttest{
#codes
ons_codes(code_id = "quarter", edition = "one-off")
#>   code label                                        links.href
#> 1   q4    Q4 https://api.beta.ons.gov.uk/v1/code-lists/quarter
#> 2   q3    Q3 https://api.beta.ons.gov.uk/v1/code-lists/quarter
#> 3   q2    Q2 https://api.beta.ons.gov.uk/v1/code-lists/quarter
#> 4   q1    Q1 https://api.beta.ons.gov.uk/v1/code-lists/quarter
#>                                                                             links.href
#> 1 https://api.beta.ons.gov.uk/v1/code-lists/quarter/editions/one-off/codes/q4/datasets
#> 2 https://api.beta.ons.gov.uk/v1/code-lists/quarter/editions/one-off/codes/q3/datasets
#> 3 https://api.beta.ons.gov.uk/v1/code-lists/quarter/editions/one-off/codes/q2/datasets
#> 4 https://api.beta.ons.gov.uk/v1/code-lists/quarter/editions/one-off/codes/q1/datasets
#>                                                               links.self.href
#> 1 https://api.beta.ons.gov.uk/v1/code-lists/quarter/editions/one-off/codes/q4
#> 2 https://api.beta.ons.gov.uk/v1/code-lists/quarter/editions/one-off/codes/q3
#> 3 https://api.beta.ons.gov.uk/v1/code-lists/quarter/editions/one-off/codes/q2
#> 4 https://api.beta.ons.gov.uk/v1/code-lists/quarter/editions/one-off/codes/q1
#>   links.self.id
#> 1            q4
#> 2            q3
#> 3            q2
#> 4            q1
ons_code(code_id = "quarter", edition = "one-off", code = "q2")
#> $code
#> [1] "q2"
#> 
#> $label
#> [1] ""
#> 
#> $links
#> $links$code_list
#> $links$code_list$href
#> [1] "https://api.beta.ons.gov.uk/v1/code-lists/quarter"
#> 
#> 
#> $links$datasets
#> $links$datasets$href
#> [1] "https://api.beta.ons.gov.uk/v1/code-lists/quarter/editions/one-off/codes/q2/datasets"
#> 
#> 
#> $links$self
#> $links$self$href
#> [1] "https://api.beta.ons.gov.uk/v1/code-lists/quarter/editions/one-off/codes/q2"
#> 
#> $links$self$id
#> [1] "q2"
#> 
#> 
#> 

ons_code_dataset(code_id = "quarter", edition = "one-off", code = "q2")
#> list()
# }