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()
.
ons_get(
id = NULL,
edition = NULL,
version = NULL,
ons_read = getOption("onsr.read"),
...
)
ons_get_obs(id = NULL, edition = NULL, version = NULL, ...)
[character]
Id that represents a dataset.
[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.
[character]
A specific instance of the edition at a point in time. New
versions can be published as a result of corrections, revisions or new data
becoming available.
[character]
. Reading backend, one of readr
, data.table
or vroom
.
Further arguments passed on the methods.
A tibble with the dataset in tidy format.
# \donttest{
ons_get(id = "cpih01")
#> # A tibble: 49,776 × 7
#> v4_0 `mmm-yy` Time `uk-only` Geography cpih1dim1aggid Aggregate
#> <dbl> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 0 Jan-88 Jan-88 K02000001 United Kingdom CP0915 09.1.5 Repair …
#> 2 62 Jan-88 Jan-88 K02000001 United Kingdom CP1212_1213 12.1.2/3 Appli…
#> 3 22.3 Jan-88 Jan-88 K02000001 United Kingdom CP073 07.3 Transport…
#> 4 154. Jan-88 Jan-88 K02000001 United Kingdom CP032 03.2 Footwear …
#> 5 57 Jan-88 Jan-88 K02000001 United Kingdom CP0561 05.6.1 Non-dur…
#> 6 120. Jan-88 Jan-88 K02000001 United Kingdom CP052 05.2 Household…
#> 7 45.1 Jan-88 Jan-88 K02000001 United Kingdom CP012 01.2 Non-alcoh…
#> 8 127. Jan-88 Jan-88 K02000001 United Kingdom CP0711N2 07.1.1b Second…
#> 9 97 Jan-88 Jan-88 K02000001 United Kingdom CP08 08 Communicati…
#> 10 53.7 Jan-88 Jan-88 K02000001 United Kingdom CP0112 01.1.2 Meat
#> # … with 49,766 more rows
# Same dataset but older version
ons_get(id = "cpih01", version = "5")
#> # A tibble: 55,977 × 7
#> v4_0 `mmm-yy` Time `uk-only` Geography cpih1dim1aggid Aggregate
#> <dbl> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 90.9 Jul-11 Jul-11 K02000001 United Kingdom cpih1dim1G110100 11.1 Caterin…
#> 2 68.7 Feb-98 Feb-98 K02000001 United Kingdom cpih1dim1S10102 01.1.2 Meat
#> 3 94.9 Mar-12 Mar-12 K02000001 United Kingdom cpih1dim1S80200 08.2.0 Telep…
#> 4 84.9 Aug-93 Aug-93 K02000001 United Kingdom cpih1dim1S120102 12.1.2/3 App…
#> 5 102. Dec-12 Dec-12 K02000001 United Kingdom cpih1dim1S50200 05.2.0 House…
#> 6 91.4 Apr-91 Apr-91 K02000001 United Kingdom cpih1dim1S90303 09.3.3 Garde…
#> 7 0 Jun-96 Jun-96 K02000001 United Kingdom cpih1dim1S120400 12.4.0 Socia…
#> 8 108. Mar-03 Mar-03 K02000001 United Kingdom cpih1dim1S50200 05.2.0 House…
#> 9 30.8 May-96 May-96 K02000001 United Kingdom cpih1dim1G20200 02.2 Tobacco
#> 10 85.3 Jun-99 Jun-99 K02000001 United Kingdom cpih1dim1G50500 05.5 Tools a…
#> # … with 55,967 more rows
# }
# \donttest{
# Take only specific observations
ons_get_obs("cpih01", geography = "K02000001", aggregate = "cpih1dim1A0", time = "Oct-11")
#> Fetched 0/0 (limit = 10000, offset = 0)
#> # A tibble: 0 × 0
# Or can use a wildcard for the time
ons_get_obs("cpih01", geography = "K02000001", aggregate = "cpih1dim1A0", time = "*")
#> Fetched 0/0 (limit = 10000, offset = 0)
#> # A tibble: 0 × 0
# }