diff --git a/R/data.R b/R/data.R index 1235f56..9d73373 100644 --- a/R/data.R +++ b/R/data.R @@ -435,6 +435,55 @@ NULL #' @source \url{https://www.gov.uk/government/statistics/english-indices-of-deprivation-2025} "imd2025_england_ltla24" +#' Index of Multiple Deprivation for LSOAs (2021) in Wales. +#' +#' A data set containing IMD scores, ranks and deciles for Lower Layer Super +#' Output Areas (LSOAs) in Wales. Lower numbers indicate more deprivation, higher numbers indicate less deprivation. +#' +#' @format A data frame of class "tbl": +#' \describe{ +#' \item{lsoa21_code}{LSOA code} +#' \item{IMD_rank}{IMD rank} +#' \item{Income_rank}{Income domain rank} +#' \item{Employment_rank}{Employment domain rank} +#' \item{Education_rank}{Education domain rank} +#' \item{Health_rank}{Health domain rank} +#' \item{Access_rank}{Access to services domain rank} +#' \item{Housing_rank}{Housing domain rank} +#' \item{Crime_rank}{Community safety domain rank} +#' \item{Environment_rank}{Environment domain rank} +#' +#' \item{IMD_decile}{IMD decile} +#' \item{Income_decile}{Income domain decile} +#' \item{Employment_decile}{Employment domain decile} +#' \item{Health_decile}{Health and Disability domain decile} +#' \item{Education_decile}{Education domain decile} +#' \item{Access_decile}{Housing domain score} +#' \item{Housing_decile}{Housing domain decile} +#' \item{Crime_decile}{Community safety domain decile} +#' \item{Environment_decile}{Environment domain decile} +#' +#' \item{IMD_score}{IMD score} +#' \item{Income_score}{Income domain score} +#' \item{Employment_score}{Employment domain score} +#' \item{Health_score}{Health domain score} +#' \item{Education_score}{Education domain score} +#' \item{Access_score}{Housing domain score} +#' \item{Housing_score}{Housing domain score} +#' \item{Crime_score}{Community safety domain score} +#' \item{Environment_score}{Physical environment domain score} +#' \item{Category_of_deeprooted_deprivation}{ +#' Four categories of deep-rooted deprivation: +#' \cr 1. LSOAs in deep rooted deprivation: These LSOAs have remained in the top 50 most deprvied for the last 6 publications of WIMD ranks. +#' \cr 2. LSOAs often ranked in top 50 most deprived: These LSOAs have been in the top 50 most deprived for between 3 and 5 of the last 6 publications of WIMD ranks. +#' \cr 3. LSOAs sometimes ranked in top 50 most deprived: These LSOAs have been in the top 50 most deprived for 1 or 2 of the last 6 publications of WIMD ranks. +#' \cr 4. LSOAs never ranked in top 50 most deprived: The LSOAs have never been in the top 50 most deprived for the last 6 publications of WIMD ranks. +#' } +#' ... +#' } +#' @source \url{https://www.gov.wales/welsh-index-multiple-deprivation-2025} +"imd2025_wales_lsoa21" + #' Index of Multiple Deprivation for LSOAs (2011) in England #' #' A data set containing IMD scores and deciles for Lower Layer Super diff --git a/R/sysdata.rda b/R/sysdata.rda index 9372305..9386158 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/data-raw/imd2025_wales_lsoa21.R b/data-raw/imd2025_wales_lsoa21.R new file mode 100644 index 0000000..7c93a54 --- /dev/null +++ b/data-raw/imd2025_wales_lsoa21.R @@ -0,0 +1,119 @@ +library(tidyverse) +library(devtools) +library(readODS) + +# Load package +load_all(".") + +# Get ranks and deciles +query_url <- + query_urls |> + filter(data_set == "imd2025_lsoa21_wales_ranks") |> + pull(query_url) + +tf <- tempfile(fileext = ".ods") + +request(query_url) |> + req_perform(path = tf) + +imd_wales_lsoa_ranks <- + readODS::read_ods(tf, sheet = "WIMD_2025_ranks", skip = 2) + +names(imd_wales_lsoa_ranks) <- str_trim(names(imd_wales_lsoa_ranks)) + +ranks_deciles <- + imd_wales_lsoa_ranks |> + + select(-ncol(imd_wales_lsoa_ranks)) |> + as_tibble() |> + + select( + lsoa21_code = `LSOA code`, + IMD_rank = `WIMD 2025`, + Income_rank = `Income`, + Employment_rank = Employment, + Health_rank = Health, + Education_rank = Education, + Access_rank = `Access to Services`, + Housing_rank = Housing, + Crime_rank = `Community Safety`, + Environment_rank = `Physical Environment`, + ) |> + + mutate( + IMD_decile = ntile(`IMD_rank`, 10), + Income_decile = ntile(`Income_rank`, 10), + Employment_decile = ntile(`Employment_rank`, 10), + Health_decile = ntile(`Health_rank`, 10), + Education_decile = ntile(`Education_rank`, 10), + Access_decile = ntile(`Access_rank`, 10), + Housing_decile = ntile(`Housing_rank`, 10), + Crime_decile = ntile(`Crime_rank`, 10), + Environment_decile = ntile(`Environment_rank`, 10) + ) + +# Get scores +query_url <- + query_urls |> + filter(data_set == "imd2025_lsoa21_wales_scores") |> + pull(query_url) + +tf <- tempfile(fileext = ".ods") + +request(query_url) |> + req_perform(path = tf) + +imd_wales_lsoa_scores <- + readODS::read_ods(tf, sheet = "Data", skip = 3) + +names(imd_wales_lsoa_scores) <- str_trim(names(imd_wales_lsoa_scores)) + +scores <- + imd_wales_lsoa_scores |> + as_tibble() |> + + select( + lsoa21_code = `LSOA code`, + IMD_score = `WIMD 2025`, + Income_score = `Income`, + Employment_score = Employment, + Health_score = Health, + Education_score = Education, + Access_score = `Access to Services`, + Housing_score = Housing, + Crime_score = `Community Safety`, + Environment_score = `Physical Environment` + ) + +# Get deep rooted deprivation +query_url <- + query_urls |> + filter(data_set == "imd2025_lsoa21_wales_deeprooteddep") |> + pull(query_url) + +tf <- tempfile(fileext = ".ods") + +request(query_url) |> + req_perform(path = tf) + +imd_wales_lsoa_dep <- + readODS::read_ods(tf, sheet = "Data", skip = 4) + +names(imd_wales_lsoa_dep) <- str_trim(names(imd_wales_lsoa_dep)) + +dep <- + imd_wales_lsoa_dep |> + as_tibble() |> + + select( + lsoa21_code = `LSOA Code`, + category_of_deeprooted_deprivation = `Category of deep-rooted deprivation` + ) + +# Combine scores, ranks, deciles, deep rooted deprivation +imd2025_wales_lsoa21 <- ranks_deciles |> + left_join(scores) |> + left_join(dep) + +# Save output to data/ folder +usethis::use_data(imd2025_wales_lsoa21, overwrite = TRUE) diff --git a/data-raw/query_urls.R b/data-raw/query_urls.R index e099ffb..15860d8 100644 --- a/data-raw/query_urls.R +++ b/data-raw/query_urls.R @@ -18,6 +18,10 @@ query_urls <- "imd_england_subdomains" , "imd" , "Sub-domains of LSOA-level deprivation in England" , "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/833976/File_4_-_IoD2019_Sub-domains_of_Deprivation.xlsx" , "https://www.gov.uk/government/statistics/english-indices-of-deprivation-2019" , "imd_england_indicators" , "imd" , "File 8: underlying indicators" , "https://assets.publishing.service.gov.uk/media/5d8b3cd740f0b609909b590a/File_8_-_IoD2019_Underlying_Indicators.xlsx" , "https://www.gov.uk/government/statistics/english-indices-of-deprivation-2019" , # Wales + "imd2025_lsoa21_wales_ranks" , "imd" , "LSOA-level deprivation in Wales, ranks" , "https://www.gov.wales/sites/default/files/statistics-and-research/2025-11/wimd-2025-index-and-domain-ranks-by-small-area.ods" , "https://www.gov.wales/welsh-index-multiple-deprivation-2025" , + "imd2025_lsoa21_wales_scores" , "imd" , "LSOA-level deprivation in Wales, scores" , "https://www.gov.wales/sites/default/files/statistics-and-research/2025-12/wimd-2025-index-and-domain-scores-by-small-area.ods" , "https://www.gov.wales/welsh-index-multiple-deprivation-2025" , + "imd2025_lsoa21_wales_deeprooteddep" , "imd" , "LSOA-level deprivation in Wales, deep rooted deprivation" , "https://www.gov.wales/sites/default/files/statistics-and-research/2025-11/welsh-index-of-multiple-deprivation-wimd-2025-data-underlying-deep-dooted-deprivation-analysis.ods" , "https://www.gov.wales/welsh-index-multiple-deprivation-2025" , + "imd_lsoa_wales" , "imd" , "LSOA-level deprivation in Wales" , "https://www.gov.wales/sites/default/files/statistics-and-research/2022-02/welsh-index-multiple-deprivation-2019-index-and-domain-ranks-by-small-area.ods" , "https://gov.wales/welsh-index-multiple-deprivation-full-index-update-ranks-2019" , "imd_lsoa_wales_scores" , "imd" , "LSOA-level deprivation scores in Wales" , "https://www.gov.wales/sites/default/files/statistics-and-research/2022-02/wimd-2019-index-and-domain-scores-by-small-area.ods" , "https://gov.wales/welsh-index-multiple-deprivation-full-index-update-ranks-2019" , # Scotland diff --git a/data/imd2025_wales_lsoa21.rda b/data/imd2025_wales_lsoa21.rda new file mode 100644 index 0000000..dcd02c1 Binary files /dev/null and b/data/imd2025_wales_lsoa21.rda differ diff --git a/man/imd2025_wales_lsoa21.Rd b/man/imd2025_wales_lsoa21.Rd new file mode 100644 index 0000000..7699de0 --- /dev/null +++ b/man/imd2025_wales_lsoa21.Rd @@ -0,0 +1,60 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{imd2025_wales_lsoa21} +\alias{imd2025_wales_lsoa21} +\title{Index of Multiple Deprivation for LSOAs (2021) in Wales.} +\format{ +A data frame of class "tbl": +\describe{ + \item{lsoa21_code}{LSOA code} + \item{IMD_rank}{IMD rank} + \item{Income_rank}{Income domain rank} + \item{Employment_rank}{Employment domain rank} + \item{Education_rank}{Education domain rank} + \item{Health_rank}{Health domain rank} + \item{Access_rank}{Access to services domain rank} + \item{Housing_rank}{Housing domain rank} + \item{Crime_rank}{Community safety domain rank} + \item{Environment_rank}{Environment domain rank} + + \item{IMD_decile}{IMD decile} + \item{Income_decile}{Income domain decile} + \item{Employment_decile}{Employment domain decile} + \item{Health_decile}{Health and Disability domain decile} + \item{Education_decile}{Education domain decile} + \item{Access_decile}{Housing domain score} + \item{Housing_decile}{Housing domain decile} + \item{Crime_decile}{Community safety domain decile} + \item{Environment_decile}{Environment domain decile} + + \item{IMD_score}{IMD score} + \item{Income_score}{Income domain score} + \item{Employment_score}{Employment domain score} + \item{Health_score}{Health domain score} + \item{Education_score}{Education domain score} + \item{Access_score}{Housing domain score} + \item{Housing_score}{Housing domain score} + \item{Crime_score}{Community safety domain score} + \item{Environment_score}{Physical environment domain score} + \item{Category_of_deeprooted_deprivation}{ + Four categories of deep-rooted deprivation: + \cr 1. LSOAs in deep rooted deprivation: These LSOAs have remained in the top 50 most deprvied for the last 6 publications of WIMD ranks. + \cr 2. LSOAs often ranked in top 50 most deprived: These LSOAs have been in the top 50 most deprived for between 3 and 5 of the last 6 publications of WIMD ranks. + \cr 3. LSOAs sometimes ranked in top 50 most deprived: These LSOAs have been in the top 50 most deprived for 1 or 2 of the last 6 publications of WIMD ranks. + \cr 4. LSOAs never ranked in top 50 most deprived: The LSOAs have never been in the top 50 most deprived for the last 6 publications of WIMD ranks. + } + ... +} +} +\source{ +\url{https://www.gov.wales/welsh-index-multiple-deprivation-2025} +} +\usage{ +imd2025_wales_lsoa21 +} +\description{ +A data set containing IMD scores, ranks and deciles for Lower Layer Super +Output Areas (LSOAs) in Wales. Lower numbers indicate more deprivation, higher numbers indicate less deprivation. +} +\keyword{datasets}