create_custom_lookup: Uses build_api_query() to Retrieve, Tidy and Return a Lookup...

View source: R/create_custom_lookup.R

create_custom_lookupR Documentation

Uses build_api_query() to Retrieve, Tidy and Return a Lookup Table

Description

Roughly equivalent to geo_get(boundaries = FALSE)

Usage

create_custom_lookup(
  bounds_level,
  within,
  within_level,
  bounds_cd = FALSE,
  within_cd = FALSE,
  include_msoa = NULL,
  return_style = "tidy",
  include_welsh_names = NULL
)

Arguments

bounds_level

The lowest level at which to return codes and names, eg "LSOA". Has to be one of "lsoa", "msoa", "wd/ward", "lad", "cty/county". Case-insensitive.

within

The name of a geographic area to filter by eg "Swindon", "Gloucestershire", "Wales", or a set of area codes (with bounds_cd or within_cd).

within_level

Upper geographic level to filter at. eg if filtering to find all LSOAs in a local authority, within_level will be "lad". Has to be one of "wd/ward", "lad/ltla", "cty/county", "utla/upper", "rgn/region", "cauth" or "ctry/country". Case-insensitive. Not all combinations of bounds_level and within_level make sense or are possible! NB "county" includes metropolitan counties such as "Tyne and Wear" and "West Midlands".

bounds_cd

When you just supply a list of area codes for places you want boundaries for. NB this relates to lower areas, "bounds" level.

within_cd

Usually you'll build the query with a place name to search within. But sometimes you may wish to pass in a vector of area codes instead (if that's all you have, or more likely if you are querying within wards, which don't have unique names (there's a lot of Abbey wards in England!)). If you're passing in area codes not names, set this to TRUE. NB this only applies to the higher, "within", level.

include_msoa

If bounds_level = LSOA and return_style = "tidy", whether to also include MSOA columns (in "tidy" return style). If bounds_level is MSOA, this will be forced to TRUE.

return_style

"tidy" (the default) means all available columns between bounds_level and within_level will be returned, but with any empty columns removed. "simple" means that only the code and name (cd and nm) columns for bounds_level and within_level are returned - other columns are omitted. "minimal" means 'only return the columns for bounds_level'.

include_welsh_names

Only makes a difference when bounds_level = msoa, or when bounds_level = lsoa and return_style = "tidy". FALSE returns no Welsh language columns. TRUE attempts to return Welsh language LAD and MSOA names where relevant. NULL (the default) means that an educated decision will be made by the program, based on whether any of the areas returned have "W" codes.

Value

a data frame (tibble)

Examples

## Not run: 
create_custom_lookup(
  bounds_level = "msoa",
  within = "Swindon",
  within_level = "lad",
  return_style = "simple"
)

## End(Not run)
## Not run: 
create_custom_lookup(
  bounds_level = "msoa",
  within = "Swansea",
  within_level = "lad",
  return_style = "tidy"
)

## End(Not run)

francisbarton/jogger documentation built on Nov. 18, 2022, 2:46 p.m.