diff --git a/R/data.R b/R/data.R index 021bcea..f295e06 100644 --- a/R/data.R +++ b/R/data.R @@ -1245,44 +1245,6 @@ #' @source \url{https://geoportal.statistics.gov.uk/} "lookup_postcode_dz21_sdz21_dea14_lgd14" -#' Postcode to Output Area (2011) to Lower Layer Super Output Area (2011) to -#' Middle Layer Super Output Area (2011) to Local Authority District (2020) -#' Lookup -#' -#' A data set containing a lookup between postcodes, OAs, LSOAs, MSOAs, and -#' 2020 Local Authority Districts, for England, Wales, and Scotland. -#' -#' @format A data frame of class "tbl" with 2,568,780 rows and 5 variables: -#' \describe{ -#' \item{postcode}{Postcodes} -#' \item{oa11_code}{OA code} -#' \item{lsoa11_code}{LSOA code} -#' \item{msoa11_code}{MSOA code} -#' \item{ltla20_code}{LAD code} -#' ... -#' } -#' @source \url{https://geoportal.statistics.gov.uk/} -"lookup_postcode_oa11_lsoa11_msoa11_ltla20" - -#' Postcode to Output Area (2021) to Lower Layer Super Output Area (2021) to -#' Middle Layer Super Output Area (2021) to Local Authority District (2022) -#' Lookup -#' -#' A data set containing a lookup between postcodes, OAs, LSOAs, MSOAs, and -#' 2022 Local Authority Districts, for England, Wales, and Scotland. -#' -#' @format A data frame of class "tbl" with 2,600,236 rows and 5 variables: -#' \describe{ -#' \item{postcode}{Postcodes} -#' \item{oa21_code}{OA code} -#' \item{lsoa21_code}{LSOA code} -#' \item{msoa21_code}{MSOA code} -#' \item{ltla22_code}{LAD code} -#' ... -#' } -#' @source \url{https://geoportal.statistics.gov.uk/} -"lookup_postcode_oa21_lsoa21_msoa21_ltla22" - #' Postcode (2025) to Output Area (2011 and 2021) to Lower Layer Super Output Area #' (2011 and 2021) to Middle Layer Super Output Area (2011 and 2021) to Local #' Authority District (2024) Lookup diff --git a/data-raw/lookup_postcode_oa11_lsoa11_msoa11_ltla20.R b/data-raw/lookup_postcode_oa11_lsoa11_msoa11_ltla20.R index 00e2e04..aea84b4 100644 --- a/data-raw/lookup_postcode_oa11_lsoa11_msoa11_ltla20.R +++ b/data-raw/lookup_postcode_oa11_lsoa11_msoa11_ltla20.R @@ -1,63 +1,63 @@ -# ---- Load ---- -library(tidyverse) -library(devtools) -library(httr) - -# Load package -load_all(".") - -# Set query url -query_url <- - query_urls |> - filter(id == "postcode_oa11_lsoa11_msoa11_ltla20") |> - pull(query) - -# GET and unzip file -GET( - query_url, - write_disk(zip_folder <- tempfile(fileext = ".zip")) -) - -unzip(zip_folder, exdir = tempdir()) - -file <- file.path(tempdir(), "NSPCL_NOV20_UK_LU.csv") - -postcodes <- - read_csv(file) - -# Select and rename vars -postcode_oa_lsoa_msoa_lad <- - postcodes |> - select( - postcode = pcds, - oa11_code = oa11cd, - lsoa11_code = lsoa11cd, - msoa11_code = msoa11cd, - ltla20_code = ladcd - ) - -# Keep distinct values and clean postcode column -postcode_oa_lsoa_msoa_lad <- - postcode_oa_lsoa_msoa_lad |> - mutate(postcode = str_to_upper(postcode)) |> - mutate(postcode = str_remove_all(postcode, " ")) |> - distinct() - -# Remove NI Postcodes which are distributed under their own license: -# https://www.ons.gov.uk/methodology/geography/licences - -# Keep only Valid codes, as two "pseudo" codes appear in the data: -# "L99999999" & "M99999999" -postcode_oa_lsoa_msoa_lad <- - postcode_oa_lsoa_msoa_lad |> - filter( - str_detect(ltla20_code, "^E") | - str_detect(ltla20_code, "^W") | - str_detect(ltla20_code, "^S") - ) - -# Rename -lookup_postcode_oa11_lsoa11_msoa11_ltla20 <- postcode_oa_lsoa_msoa_lad - -# Save output to data/ folder -usethis::use_data(lookup_postcode_oa11_lsoa11_msoa11_ltla20, overwrite = TRUE) +# # ---- Load ---- +# library(tidyverse) +# library(devtools) +# library(httr) +# +# # Load package +# load_all(".") +# +# # Set query url +# query_url <- +# query_urls |> +# filter(id == "postcode_oa11_lsoa11_msoa11_ltla20") |> +# pull(query) +# +# # GET and unzip file +# GET( +# query_url, +# write_disk(zip_folder <- tempfile(fileext = ".zip")) +# ) +# +# unzip(zip_folder, exdir = tempdir()) +# +# file <- file.path(tempdir(), "NSPCL_NOV20_UK_LU.csv") +# +# postcodes <- +# read_csv(file) +# +# # Select and rename vars +# postcode_oa_lsoa_msoa_lad <- +# postcodes |> +# select( +# postcode = pcds, +# oa11_code = oa11cd, +# lsoa11_code = lsoa11cd, +# msoa11_code = msoa11cd, +# ltla20_code = ladcd +# ) +# +# # Keep distinct values and clean postcode column +# postcode_oa_lsoa_msoa_lad <- +# postcode_oa_lsoa_msoa_lad |> +# mutate(postcode = str_to_upper(postcode)) |> +# mutate(postcode = str_remove_all(postcode, " ")) |> +# distinct() +# +# # Remove NI Postcodes which are distributed under their own license: +# # https://www.ons.gov.uk/methodology/geography/licences +# +# # Keep only Valid codes, as two "pseudo" codes appear in the data: +# # "L99999999" & "M99999999" +# postcode_oa_lsoa_msoa_lad <- +# postcode_oa_lsoa_msoa_lad |> +# filter( +# str_detect(ltla20_code, "^E") | +# str_detect(ltla20_code, "^W") | +# str_detect(ltla20_code, "^S") +# ) +# +# # Rename +# lookup_postcode_oa11_lsoa11_msoa11_ltla20 <- postcode_oa_lsoa_msoa_lad +# +# # Save output to data/ folder +# usethis::use_data(lookup_postcode_oa11_lsoa11_msoa11_ltla20, overwrite = TRUE) diff --git a/data-raw/lookup_postcode_oa21_lsoa21_msoa21_ltla22.R b/data-raw/lookup_postcode_oa21_lsoa21_msoa21_ltla22.R index ad6af59..af54f0a 100644 --- a/data-raw/lookup_postcode_oa21_lsoa21_msoa21_ltla22.R +++ b/data-raw/lookup_postcode_oa21_lsoa21_msoa21_ltla22.R @@ -1,63 +1,63 @@ -# ---- Load ---- -library(tidyverse) -library(devtools) -library(httr) - -# Load package -load_all(".") - -# Set query url -query_url <- - query_urls |> - filter(id == "postcode_oa21_lsoa21_msoa21_ltla22") |> - pull(query) - -# GET and unzip file -GET( - query_url, - write_disk(zip_folder <- tempfile(fileext = ".zip")) -) - -unzip(zip_folder, exdir = tempdir()) - -file <- file.path(tempdir(), "PCD_OA21_LSOA21_MSOA21_LAD_NOV22_UK_LU.csv") - -postcodes <- - read_csv(file) - -# Select and rename vars -postcode_oa_lsoa_msoa_lad <- - postcodes |> - select( - postcode = pcds, - oa21_code = oa21cd, - lsoa21_code = lsoa21cd, - msoa21_code = msoa21cd, - ltla22_code = ladcd - ) - -# Keep distinct values and clean postcode column -postcode_oa_lsoa_msoa_lad <- - postcode_oa_lsoa_msoa_lad |> - mutate(postcode = str_to_upper(postcode)) |> - mutate(postcode = str_remove_all(postcode, " ")) |> - distinct() - -# Remove NI Postcodes which are distributed under their own license: -# https://www.ons.gov.uk/methodology/geography/licences - -# Keep only Valid codes, as two "pseudo" codes appear in the data: -# "L99999999" & "M99999999" -postcode_oa_lsoa_msoa_lad <- - postcode_oa_lsoa_msoa_lad |> - filter( - str_detect(ltla22_code, "^E") | - str_detect(ltla22_code, "^W") | - str_detect(ltla22_code, "^S") - ) - -# Rename -lookup_postcode_oa21_lsoa21_msoa21_ltla22 <- postcode_oa_lsoa_msoa_lad - -# Save output to data/ folder -usethis::use_data(lookup_postcode_oa21_lsoa21_msoa21_ltla22, overwrite = TRUE) +# # ---- Load ---- +# library(tidyverse) +# library(devtools) +# library(httr) +# +# # Load package +# load_all(".") +# +# # Set query url +# query_url <- +# query_urls |> +# filter(id == "postcode_oa21_lsoa21_msoa21_ltla22") |> +# pull(query) +# +# # GET and unzip file +# GET( +# query_url, +# write_disk(zip_folder <- tempfile(fileext = ".zip")) +# ) +# +# unzip(zip_folder, exdir = tempdir()) +# +# file <- file.path(tempdir(), "PCD_OA21_LSOA21_MSOA21_LAD_NOV22_UK_LU.csv") +# +# postcodes <- +# read_csv(file) +# +# # Select and rename vars +# postcode_oa_lsoa_msoa_lad <- +# postcodes |> +# select( +# postcode = pcds, +# oa21_code = oa21cd, +# lsoa21_code = lsoa21cd, +# msoa21_code = msoa21cd, +# ltla22_code = ladcd +# ) +# +# # Keep distinct values and clean postcode column +# postcode_oa_lsoa_msoa_lad <- +# postcode_oa_lsoa_msoa_lad |> +# mutate(postcode = str_to_upper(postcode)) |> +# mutate(postcode = str_remove_all(postcode, " ")) |> +# distinct() +# +# # Remove NI Postcodes which are distributed under their own license: +# # https://www.ons.gov.uk/methodology/geography/licences +# +# # Keep only Valid codes, as two "pseudo" codes appear in the data: +# # "L99999999" & "M99999999" +# postcode_oa_lsoa_msoa_lad <- +# postcode_oa_lsoa_msoa_lad |> +# filter( +# str_detect(ltla22_code, "^E") | +# str_detect(ltla22_code, "^W") | +# str_detect(ltla22_code, "^S") +# ) +# +# # Rename +# lookup_postcode_oa21_lsoa21_msoa21_ltla22 <- postcode_oa_lsoa_msoa_lad +# +# # Save output to data/ folder +# usethis::use_data(lookup_postcode_oa21_lsoa21_msoa21_ltla22, overwrite = TRUE) diff --git a/data/lookup_postcode_oa11_lsoa11_msoa11_ltla20.rda b/data/lookup_postcode_oa11_lsoa11_msoa11_ltla20.rda deleted file mode 100644 index 5c05183..0000000 Binary files a/data/lookup_postcode_oa11_lsoa11_msoa11_ltla20.rda and /dev/null differ diff --git a/data/lookup_postcode_oa21_lsoa21_msoa21_ltla22.rda b/data/lookup_postcode_oa21_lsoa21_msoa21_ltla22.rda deleted file mode 100644 index ede560d..0000000 Binary files a/data/lookup_postcode_oa21_lsoa21_msoa21_ltla22.rda and /dev/null differ diff --git a/man/lookup_postcode_oa11_lsoa11_msoa11_ltla20.Rd b/man/lookup_postcode_oa11_lsoa11_msoa11_ltla20.Rd deleted file mode 100644 index 31aff60..0000000 --- a/man/lookup_postcode_oa11_lsoa11_msoa11_ltla20.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{lookup_postcode_oa11_lsoa11_msoa11_ltla20} -\alias{lookup_postcode_oa11_lsoa11_msoa11_ltla20} -\title{Postcode to Output Area (2011) to Lower Layer Super Output Area (2011) to -Middle Layer Super Output Area (2011) to Local Authority District (2020) -Lookup} -\format{ -A data frame of class "tbl" with 2,568,780 rows and 5 variables: -\describe{ -\item{postcode}{Postcodes} -\item{oa11_code}{OA code} -\item{lsoa11_code}{LSOA code} -\item{msoa11_code}{MSOA code} -\item{ltla20_code}{LAD code} -... -} -} -\source{ -\url{https://geoportal.statistics.gov.uk/} -} -\usage{ -lookup_postcode_oa11_lsoa11_msoa11_ltla20 -} -\description{ -A data set containing a lookup between postcodes, OAs, LSOAs, MSOAs, and -2020 Local Authority Districts, for England, Wales, and Scotland. -} -\keyword{datasets} diff --git a/man/lookup_postcode_oa21_lsoa21_msoa21_ltla22.Rd b/man/lookup_postcode_oa21_lsoa21_msoa21_ltla22.Rd deleted file mode 100644 index 506ecae..0000000 --- a/man/lookup_postcode_oa21_lsoa21_msoa21_ltla22.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{lookup_postcode_oa21_lsoa21_msoa21_ltla22} -\alias{lookup_postcode_oa21_lsoa21_msoa21_ltla22} -\title{Postcode to Output Area (2021) to Lower Layer Super Output Area (2021) to -Middle Layer Super Output Area (2021) to Local Authority District (2022) -Lookup} -\format{ -A data frame of class "tbl" with 2,600,236 rows and 5 variables: -\describe{ -\item{postcode}{Postcodes} -\item{oa21_code}{OA code} -\item{lsoa21_code}{LSOA code} -\item{msoa21_code}{MSOA code} -\item{ltla22_code}{LAD code} -... -} -} -\source{ -\url{https://geoportal.statistics.gov.uk/} -} -\usage{ -lookup_postcode_oa21_lsoa21_msoa21_ltla22 -} -\description{ -A data set containing a lookup between postcodes, OAs, LSOAs, MSOAs, and -2022 Local Authority Districts, for England, Wales, and Scotland. -} -\keyword{datasets}