Create a lookup table by querying the ONS OpenGeography API
lookup.RdCreate 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 than- lookup!). If not supplied, this uses the default- NULL, and just data for- lookup_levelwill be returned. In this case,- within_namesand- within_codes(if supplied) will instead be taken to refer to, and used to filter at, the- lookup_levellevel.
- within_names, within_codes
- character. In order to restrict data returned to a specific area, either - within_namesor- within_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 filter- within_level, the- within_levelmust be specified! Otherwise- {boundr}will apply them to- lookup_levelinstead. See examples. Vectors of multiple names or multiple codes can be supplied. If you supply both- within_namesand- within_codes, only- within_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 to- NULL, 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 to- NULL, 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                    lad24cd   lad24nm
#>    <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 × 9
#>    wd23cd    wd23nm wd23nmw ua23cd ua23nm ua23nmw sener23cd sener23nm sener23nmw
#>    <chr>     <chr>  <chr>   <chr>  <chr>  <chr>   <chr>     <chr>     <chr>     
#>  1 W05001492 Aethwy Aethwy  W0600… Isle … Ynys M… W10000001 North Wa… Gogledd C…
#>  2 W05001493 Bodow… Bodowyr W0600… Isle … Ynys M… W10000001 North Wa… Gogledd C…
#>  3 W05001494 Bro A… Bro Ab… W0600… Isle … Ynys M… W10000001 North Wa… Gogledd C…
#>  4 W05001495 Bro'r… Bro'r … W0600… Isle … Ynys M… W10000001 North Wa… Gogledd C…
#>  5 W05001496 Canol… Canolb… W0600… Isle … Ynys M… W10000001 North Wa… Gogledd C…
#>  6 W05001497 Cefni  Cefni   W0600… Isle … Ynys M… W10000001 North Wa… Gogledd C…
#>  7 W05001498 Crigy… Crigyll W0600… Isle … Ynys M… W10000001 North Wa… Gogledd C…
#>  8 W05001499 Lligwy Lligwy  W0600… Isle … Ynys M… W10000001 North Wa… Gogledd C…
#>  9 W05001500 Parc … Parc a… W0600… Isle … Ynys M… W10000001 North Wa… Gogledd C…
#> 10 W05001501 Seiri… Seiriol W0600… Isle … Ynys M… W10000001 North Wa… Gogledd C…
#> # ℹ 754 more rows