Create a lookup table by querying the ONS OpenGeography API
Usage
lookup(
lookup_level,
within_level = NULL,
within_names = NULL,
within_codes = NULL,
lookup_year = NULL,
within_year = NULL,
opts = boundr_options()
)Arguments
- lookup_level
character. Lower level area code eg "lsoa", "wd", "lad".
- within_level
character. Higher level area code eg "lad", "cty", "icb". (That is, higher (conceptually) than
lookup_level; aka larger thanlookup!). If not supplied, this uses the defaultNULL, and just data forlookup_levelwill be returned. In this case,within_namesandwithin_codes(if supplied) will instead be taken to refer to, and used to filter at, thelookup_levellevel.- within_names, within_codes
character. In order to restrict data returned to a specific area, either
within_namesorwithin_codesmust be provided. Otherwise all available boundaries at that level will be retrieved. Use place names eg "Essex" to restrict to a certain geographical area. Or use ONS area codes eg "W02000103" likewise (this is useful with wards, where there are many that share identical names). To use this argument to filterwithin_level, thewithin_levelmust be specified! Otherwise{boundr}will apply them tolookup_levelinstead. See examples. Vectors of multiple names or multiple codes can be supplied. If you supply bothwithin_namesandwithin_codes, onlywithin_nameswill be used; (within_codeswill be ignored).- lookup_year
numeric or character. A specific year for data relating to
lookup_level, if you need it. Defaults toNULL, which then aims to return data for the most recent year available. Provide as YYYY.- within_year
numeric or character. A specific year for data relating to
within_level, if you need it. Defaults toNULL, which then aims to return data for the most recent year available. Provide as YYYY.- opts
Should be set with the
boundr_options()function. See?boundr_optionsfor detail on what can be set by the user, and on the default values.
Examples
lookup("msoa", "lad", "Swindon")
#> # A tibble: 27 × 5
#> msoa21cd msoa21nm msoa21hclnm lad25cd lad25nm
#> <chr> <chr> <chr> <chr> <chr>
#> 1 E02003230 Swindon 019 Central South & Eastcott E06000030 Swindon
#> 2 E02003221 Swindon 010 Gorse Hill E06000030 Swindon
#> 3 E02003231 Swindon 020 Park North & Park South E06000030 Swindon
#> 4 E02003229 Swindon 018 Freshbrook North & Grange Park E06000030 Swindon
#> 5 E02003233 Swindon 022 Freshbrook South & Toothill E06000030 Swindon
#> 6 E02003223 Swindon 012 Rodbourne & Cheney Manor E06000030 Swindon
#> 7 E02003235 Swindon 024 Lawn & East Wichel E06000030 Swindon
#> 8 E02003232 Swindon 021 Kingshill & Okus E06000030 Swindon
#> 9 E02006847 Swindon 026 Mouldon Hill & Oakhurst E06000030 Swindon
#> 10 E02003218 Swindon 007 Pinehurst E06000030 Swindon
#> # ℹ 17 more rows
lookup("wd", "sener", opts = opts(return_width = "full"))
#> # A tibble: 764 × 8
#> wd24cd wd24nm ua24cd ua24nm ua24nmw sener24cd sener24nm sener24nmw
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 W05001332 Alyn Valley W0600… Denbi… Sir Dd… W10000001 North Wa… Gogledd C…
#> 2 W05001333 Bodelwyddan W0600… Denbi… Sir Dd… W10000001 North Wa… Gogledd C…
#> 3 W05001334 Denbigh Caled… W0600… Denbi… Sir Dd… W10000001 North Wa… Gogledd C…
#> 4 W05001335 Denbigh Lower W0600… Denbi… Sir Dd… W10000001 North Wa… Gogledd C…
#> 5 W05001336 Dyserth W0600… Denbi… Sir Dd… W10000001 North Wa… Gogledd C…
#> 6 W05001337 Edeirnion W0600… Denbi… Sir Dd… W10000001 North Wa… Gogledd C…
#> 7 W05001338 Efenechdyd W0600… Denbi… Sir Dd… W10000001 North Wa… Gogledd C…
#> 8 W05001339 Llandyrnog W0600… Denbi… Sir Dd… W10000001 North Wa… Gogledd C…
#> 9 W05001340 Llanfair Dyff… W0600… Denbi… Sir Dd… W10000001 North Wa… Gogledd C…
#> 10 W05001341 Llangollen W0600… Denbi… Sir Dd… W10000001 North Wa… Gogledd C…
#> # ℹ 754 more rows
