Title: | Client for the 'ONS' API |
Version: | 1.0.2 |
Description: | Client for the 'Office of National Statistics' ('ONS') API https://api.beta.ons.gov.uk/v1. |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | httr, jsonlite, readr, tibble |
URL: | https://kvasilopoulos.github.io/onsr/ |
BugReports: | https://github.com/kvasilopoulos/onsr/issues |
RoxygenNote: | 7.2.3 |
Suggests: | testthat (≥ 3.0.0), data.table, vroom, curl |
Config/testthat/edition: | 3 |
Depends: | R (≥ 2.10) |
NeedsCompilation: | no |
Packaged: | 2023-12-20 15:52:51 UTC; User |
Author: | Kostas Vasilopoulos [aut, cre] |
Maintainer: | Kostas Vasilopoulos <k.vasilopoulo@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2023-12-21 11:40:02 UTC |
The Dataset with a size column
Description
The Dataset with a size column
Usage
dataset_size
Format
An object of class data.frame
with 41 rows and 3 columns.
Quickly browse to ONS' developer webpage
Description
This function take you to the ONS' developer webpage.
Usage
ons_browse()
Value
An atomic character vector with the url of the webpage
Examples
ons_browse()
Quickly browse to dataset's Quality and Methodology Information (QMI)
Description
This function take you to the QMI.
Usage
ons_browse_qmi(id = NULL)
Arguments
id |
|
Value
An atomic character vector url with of the webpage
Examples
ons_browse_qmi("cpih01")
Explore codes and lists
Description
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.
Usage
ons_codelists()
ons_codelist(code_id = NULL)
ons_codelist_editions(code_id = NULL)
ons_codelist_edition(code_id = NULL, edition = NULL)
Arguments
code_id |
|
edition |
|
Value
A list or character vector.
Examples
ons_codelists()
ons_codelist(code_id = "quarter")
#editions
ons_codelist_editions(code_id = "quarter")
ons_codelist_edition(code_id = "quarter", edition = "one-off")
Explore codes and lists
Description
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.
Usage
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 |
|
edition |
|
code |
|
Value
A list or character vector.
Examples
#codes
ons_codes(code_id = "quarter", edition = "one-off")
ons_code(code_id = "quarter", edition = "one-off", code = "q2")
ons_code_dataset(code_id = "quarter", edition = "one-off", code = "q2")
ONS Datasets
Description
A grouping of data (editions) with shared dimensions, for example Sex, Age and Geography, and all published history of this group of data. The options in these dimensions can change over time leading to separate editions. For example: Population Estimates for UK, England and Wales, Scotland and Northern Ireland.
Usage
ons_datasets()
ons_ids()
Value
A tibble with the datasets.
Examples
# Find all the information about the data
ons_datasets()
# Just the ids
ons_ids()
Description of the Dataset
Description
This function provides a description of the important information about a dataset.
Usage
ons_desc(id = NULL)
Arguments
id |
|
Value
A description of the requested dataset.
See Also
ons_meta()
Examples
ons_desc("cpih01")
Access dataset's additional information
Description
Data in each version is broken down by dimensions
, and a unique
combination of dimension options
in a version can be used to retrieve
observation
level data.
Usage
ons_dim(id = NULL, edition = NULL, version = NULL)
ons_dim_opts(
id = NULL,
edition = NULL,
version = NULL,
dimension = NULL,
limit = NULL,
offset = NULL
)
ons_meta(id = NULL, edition = NULL, version = NULL)
Arguments
id |
|
edition |
|
version |
|
dimension |
|
limit |
|
offset |
|
Value
A character vector.
Examples
## Not run:
ons_dim(id = "cpih01")
ons_dim_opts(id = "cpih01", dimension = "time")
ons_meta(id = "cpih01")
## End(Not run)
Download data from ONS
Description
This functions is used to find information about data published by the ONS.
Datasets
are published in unique versions
, which are categorized by edition
.
Available datasets are given an id
. All available id
can be viewed with ons_ids()
.
Usage
ons_get(
id = NULL,
edition = NULL,
version = NULL,
ons_read = getOption("onsr.read"),
...
)
ons_get_obs(id = NULL, edition = NULL, version = NULL, ...)
Arguments
id |
|
edition |
|
version |
|
ons_read |
|
... |
Further arguments passed on the methods. |
Value
A tibble with the dataset in tidy format.
Examples
ons_get(id = "cpih01")
# Same dataset but older version
ons_get(id = "cpih01", version = "5")
# Take only specific observations
ons_get_obs("cpih01", geography = "K02000001", aggregate = "cpih1dim1A0", time = "Oct-11")
# Or can use a wildcard for the time
ons_get_obs("cpih01", geography = "K02000001", aggregate = "cpih1dim1A0", time = "*")
Latest info on ONS Datasets
Description
This functions are used to access the latest href
, version
and edition
of a dataset.
Usage
ons_latest_href(id = NULL)
ons_latest_version(id = NULL)
ons_latest_edition(id = NULL)
Arguments
id |
|
Value
An atomic character vector with the latest info.
Examples
ons_latest_href("cpih01")
ons_latest_version("cpih01")
ons_latest_edition("cpih01")
Search for a Dataset
Description
Search for a Dataset
Usage
ons_search(id, edition = NULL, version = NULL, name = NULL, query = NULL)
Arguments
id |
|
edition |
|
version |
|
name |
|
query |
|
Value
A data.frame.
Examples
ons_dim("cpih01")
ons_search("cpih01", name = "aggregate", query = "cpih1dim1A0")