match_postcode: Retrieve ONS postcode data and append to object

View source: R/postcode_matching.R

match_postcodeR Documentation

Retrieve ONS postcode data and append to object

Description

Retrieves Office for National Statistics (ONS) data by postcode and appends it as added columns to an input file. For information on ONS databases see https://geoportal.statistics.gov.uk/datasets/national-statistics-postcode-lookup-february-2020

Usage

match_postcode(data, query_column, Index, desired_columns)

Arguments

data

data with postcodes for ONS information retrieval

query_column

name of column within dt containing postcodes to retrieve as a string

Index

index object created using index_postcodes()

desired_columns

name of ONS columns to retrieve. Default is "all"; note this excludes 2019 utla and ltla "stp19", "ccg19" geographies which are retrieved from a different database. For UTLA and LTLA "utla", "ltla" can be listed and the 2019 geographies (names and codes) will be retrieved based on the database "laua" from https://geoportal.statistics.gov.uk/datasets/lower-tier-local-authority-to-upper-tier-local-authority-april-2019-lookup-in-england-and-wales (2019 version). For the 2020 STP and CCGs lsoa11, "stp20", "ccg20" can be listed and the 2020 geographies (names and codes) will be retrieved based on the database "lsoa11" from https://geoportal.statistics.gov.uk/datasets/lsoa-2011-to-clinical-commissioning-groups-to-sustainability-and-transformation-partnerships-april-2020-lookup-in-england/data . Herefordshire CCG name is updated as per https://digital.nhs.uk/services/organisation-data-service/change-summary—stp-reconfiguration For PHEC or PHER assign c("laua", "PHEC19CD", "PHEREG19CD") to desired_columns or c("all", "PHEC19CD", "PHEREG19CD").

Value

Returns the original dt object as a data.frame with added columns of ONS data

Author(s)

Diane Hatziioanou

Examples

# Index <- fread(file.path("C:/.../NSPL_FEB_2019_UK/Data/Index.csv"))
# data_with_ONS <- match_postcode(data, "Postcode", Index, "all")


DHatziioanou/simpleepi documentation built on Sept. 24, 2024, 5:25 a.m.