match_area: Translate geography codes into area names

View source: R/match_area.R

match_areaR Documentation

Translate geography codes into area names

Description

match_area takes a geography code or vector of geography codes. It matches the input to the corresponding value in the area_lookup() dataset and returns the corresponding area name.

Usage

match_area(x)

Arguments

x

A geography code or vector of geography codes.

Details

match_area relies predominantly on the standard 9 digit geography codes. The only exceptions are:

  • RA2701: No Fixed Abode

  • RA2702: Rest of UK (Outside Scotland)

  • RA2703: Outside the UK

  • RA2704: Unknown Residency

match_area caters for both current and previous versions of geography codes (e.g 2014 and 2019 Health Boards).

It can account for geography codes pertaining to Health Boards, Council Areas, Health and Social Care Partnerships, Intermediate Zones, Data Zones (2001 and 2011), Electoral Wards, Scottish Parliamentary Constituencies, UK Parliamentary Constituencies, Travel to work areas, National Parks, Community Health Partnerships, Localities (S19), Settlements (S20) and Scotland.

match_area returns a non-NA value only when an exact match is present between the input value and the corresponding variable in the area_lookup() dataset. These exact matches are sensitive to both case and spacing. It is advised to inspect area_lookup() in the case of unexpected results, as these may be explained by subtle differences in transcription between the input value and the corresponding value in the lookup dataset.

Value

Each geography code within Scotland is unique, and consequently match_area returns a single area name for each input value. Any input value without a corresponding value in the area_lookup() dataset will return an NA output value.

Examples

match_area("S20000010")

library(dplyr)
df <- tibble(code = c("S02000656", "S02001042", "S08000020", "S12000013"))
df %>% mutate(name = match_area(code))


Health-SocialCare-Scotland/phimethods documentation built on Jan. 27, 2024, 9:49 a.m.