diff --git a/DESCRIPTION b/DESCRIPTION index db31a26..f13d5ce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,7 +11,7 @@ Description: A package to distribute and summarise on UK health data. License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Imports: tibble Depends: diff --git a/R/data.R b/R/data.R index 5fdc27b..ba5a429 100644 --- a/R/data.R +++ b/R/data.R @@ -195,7 +195,7 @@ NULL #' England Health Index (ONS) - subdomains #' -#' A dataset containing overall health index scores for the English lower tier +#' A dataset containing subdomain health index scores for the English lower tier #' local authorities from 2015-2021. #' #' @format A data frame with 2,149 rows and 16 variables: @@ -237,6 +237,59 @@ NULL #' @source \url{https://www.ons.gov.uk/} "england_health_index_indicators" +#' England Health Index (ONS) +#' +#' A dataset containing overall health index scores for the English Integrated +#' Care Boards from 2015-2021. +#' +#' @format A data frame with 294 rows and 7 variables: +#' \describe{ +#' \item{icb22_code}{2022 Integrated Care Board code} +#' \item{icb22_name}{2022 Integrated Care Board name} +#' \item{year}{Year} +#' \item{overall_score}{The overall health index score} +#' \item{healthy_people_domain_score}{Score for the Healthy People domain} +#' \item{healthy_lives_domain_score}{Score for the Healthy Lives domain} +#' \item{healthy_places_domain_score}{Score for the Healthy Places domain} +#' ... +#' } +#' @source \url{https://www.ons.gov.uk/} +"england_health_index_ics" + +#' England Health Index (ONS) - subdomains +#' +#' A dataset containing subdomain health index scores for the English Integrated +#' Care Boards from 2015-2021. +#' +#' @format A data frame with 4,116 rows and 5 variables: +#' \describe{ +#' \item{icb22_code}{2022 Integrated Care Board code} +#' \item{icb22_name}{2022 Integrated Care Board name} +#' \item{year}{Year} +#' \item{sub_domain}{The name of the subdomain} +#' \item{value}{The value of the indicator} +#' ... +#' } +#' @source \url{https://www.ons.gov.uk/} +"england_health_index_ics_indicators" + +#' England Health Index (ONS) - underlying indicators +#' +#' A dataset containing underlying indicators for the ONS Health Index for +#' English Integrated Care Boards from 2015-2021. +#' +#' @format A data frame with 16,464 rows and 5 variables: +#' \describe{ +#' \item{icb22_code}{2022 Integrated Care Board code} +#' \item{icb22_name}{2022 Integrated Care Board name} +#' \item{year}{Year} +#' \item{indicator}{The name of the indicator} +#' \item{value}{The value of the indicator} +#' ... +#' } +#' @source \url{https://www.ons.gov.uk/} +"england_health_index_ics_indicators" + #' Legal Partnership Status, England, 2021 #' #' A dataset containing legal partnership status data at LTLA level diff --git a/R/sysdata.rda b/R/sysdata.rda index 814814e..4829780 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/data-raw/england-health-index-ics.R b/data-raw/england-health-index-ics.R new file mode 100644 index 0000000..a17c2fb --- /dev/null +++ b/data-raw/england-health-index-ics.R @@ -0,0 +1,92 @@ +# ---- Load libs ---- +library(tidyverse) +library(readxl) +library(httr2) + +# ---- Load internal sysdata.rda file with URL's ---- +pkgload::load_all(".") + +# ---- Download data ---- +query_url <- + query_urls |> + filter(id == "england_health_index_ics") |> + pull(query) + +download <- tempfile(fileext = ".xlsx") + +request(query_url) |> + req_perform(download) + +# ---- Read sheets ---- +overall_scores_raw <- read_excel( + download, + sheet = "Table_2_Index_scores", + range = "A3:I45" +) + +sheet_names <- paste0("Table_", seq(3, 9), "_", seq(2021, 2015), "_Index") +index_names <- paste0("index_", seq(2021, 2015)) + +indices <- map( + .x = set_names(sheet_names, index_names), + .f = \(x) read_excel(download, sheet = x, range = "A5:BW47") +) + +# ---- Clean data ---- +overall_scores <- overall_scores_raw |> + rename(icb22_code = `Area Code`, icb22_name = `Area Name`) |> + pivot_longer( + cols = `2015`:`2021`, names_to = "year", values_to = "overall_score" + ) |> + mutate(year = as.integer(year)) + +domain_scores <- map2( + .x = indices, + .y = seq(2021, 2015), + .f = \(x, y) { + x |> + rename(icb22_code = `Area Code`, icb22_name = `Area Name`) |> + select(starts_with("icb22_"), ends_with("Domain")) |> + janitor::clean_names() |> + mutate(year = y) + } +) |> + list_rbind() + +england_health_index_ics <- left_join(overall_scores, domain_scores) + +england_health_index_ics_subdomains <- map2( + .x = indices, + .y = seq(2021, 2015), + .f = \(x, y) { + x |> + rename(icb22_code = `Area Code`, icb22_name = `Area Name`) |> + select(starts_with("icb22_"), matches("\\[(Pe|Pl|L)\\]$")) |> + rename_with(~ str_remove(., " \\[.*\\]$")) |> + janitor::clean_names() |> + pivot_longer(cols = !starts_with("icb22_"), names_to = "sub_domain") |> + mutate(year = y) |> + relocate(year, .after = "icb22_name") + } +) |> + list_rbind() + +england_health_index_ics_indicators <- map2( + .x = indices, + .y = seq(2021, 2015), + .f = \(x, y) { + x |> + rename(icb22_code = `Area Code`, icb22_name = `Area Name`) |> + select(!c(matches("\\[(Pe|Pl|L)\\]$"), matches("Domain$"))) |> + rename_with(~ str_remove(., " \\[.*\\]$")) |> + janitor::clean_names() |> + pivot_longer(cols = !starts_with("icb22_"), names_to = "indicator") |> + mutate(year = y) |> + relocate(year, .after = "icb22_name") + } +) |> + list_rbind() + +usethis::use_data(england_health_index_ics, overwrite = TRUE) +usethis::use_data(england_health_index_ics_subdomains, overwrite = TRUE) +usethis::use_data(england_health_index_ics_indicators, overwrite = TRUE) diff --git a/data-raw/query-urls.R b/data-raw/query-urls.R index 29508ac..3e48f84 100644 --- a/data-raw/query-urls.R +++ b/data-raw/query-urls.R @@ -70,6 +70,7 @@ query_urls <- "Disability", "england_disability_2021", "2021", "OGLv3", "https://www.nomisweb.co.uk/output/census/2021/census2021-ts038.zip", "https://www.nomisweb.co.uk/sources/census_2021_bulk", "Health Index", "england_health_index_2021", "June 2021", "OGLv3", "https://www.ons.gov.uk/file?uri=/peoplepopulationandcommunity/healthandsocialcare/healthandwellbeing/datasets/healthindexscoresengland/current/healthindexscoresengland.xlsx", "https://www.ons.gov.uk/peoplepopulationandcommunity/healthandsocialcare/healthandwellbeing/datasets/healthindexscoresengland", "Health Index underlying indicators", "england_health_index_2021_indicators", "June 2021", "OGLv3", "https://www.ons.gov.uk/file?uri=/peoplepopulationandcommunity/healthandsocialcare/healthandwellbeing/datasets/healthindexunderlyingdataengland/current/healthindexunderlyingdataenglandcanscreenfix.xlsx", "https://www.ons.gov.uk/peoplepopulationandcommunity/healthandsocialcare/healthandwellbeing/datasets/healthindexunderlyingdataengland", + "Health Index ICS", "england_health_index_ics", "2015-2021", "OGLv3", "https://www.ons.gov.uk/file?uri=/peoplepopulationandcommunity/healthandsocialcare/healthandwellbeing/datasets/healthindexscoresintegratedcaresystemsengland/current/healthindexscoresintegratedcaresystemsenglandcanscreeningfix.xlsx", "https://www.ons.gov.uk/peoplepopulationandcommunity/healthandsocialcare/healthandwellbeing/datasets/healthindexscoresintegratedcaresystemsengland", "Homelessness", "england_homelessness", "October to December 2023", "", "https://assets.publishing.service.gov.uk/media/662f6eccce557c60ed19ad15/Detailed_LA_202312.ods", "https://www.gov.uk/government/statistical-data-sets/live-tables-on-homelessness", "Hospital discharge (criteria to reside)", "nhs_hospital_discharge_data_april_22", "April 2022", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2022/08/Daily-discharge-sitrep-monthly-data-webfile-April2022-v2.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/discharge-delays-acute-data/", "Hospital discharge (criteria to reside)", "nhs_hospital_discharge_data_may_22", "May 2022", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2022/08/Daily-discharge-sitrep-monthly-data-webfile-May2022-v2.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/discharge-delays-acute-data/", diff --git a/data/england_health_index_ics.rda b/data/england_health_index_ics.rda new file mode 100644 index 0000000..cb2aef9 Binary files /dev/null and b/data/england_health_index_ics.rda differ diff --git a/data/england_health_index_ics_indicators.rda b/data/england_health_index_ics_indicators.rda new file mode 100644 index 0000000..abca8f3 Binary files /dev/null and b/data/england_health_index_ics_indicators.rda differ diff --git a/data/england_health_index_ics_subdomains.rda b/data/england_health_index_ics_subdomains.rda new file mode 100644 index 0000000..367463c Binary files /dev/null and b/data/england_health_index_ics_subdomains.rda differ diff --git a/man/england_health_index_ics.Rd b/man/england_health_index_ics.Rd new file mode 100644 index 0000000..cbf63d5 --- /dev/null +++ b/man/england_health_index_ics.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{england_health_index_ics} +\alias{england_health_index_ics} +\title{England Health Index (ONS)} +\format{ +A data frame with 294 rows and 7 variables: +\describe{ +\item{icb22_code}{2022 Integrated Care Board code} +\item{icb22_name}{2022 Integrated Care Board name} +\item{year}{Year} +\item{overall_score}{The overall health index score} +\item{healthy_people_domain_score}{Score for the Healthy People domain} +\item{healthy_lives_domain_score}{Score for the Healthy Lives domain} +\item{healthy_places_domain_score}{Score for the Healthy Places domain} +... +} +} +\source{ +\url{https://www.ons.gov.uk/} +} +\usage{ +england_health_index_ics +} +\description{ +A dataset containing overall health index scores for the English Integrated +Care Boards from 2015-2021. +} +\keyword{datasets} diff --git a/man/england_health_index_ics_indicators.Rd b/man/england_health_index_ics_indicators.Rd new file mode 100644 index 0000000..4550877 --- /dev/null +++ b/man/england_health_index_ics_indicators.Rd @@ -0,0 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{england_health_index_ics_indicators} +\alias{england_health_index_ics_indicators} +\title{England Health Index (ONS) - subdomains} +\format{ +A data frame with 4,116 rows and 5 variables: +\describe{ +\item{icb22_code}{2022 Integrated Care Board code} +\item{icb22_name}{2022 Integrated Care Board name} +\item{year}{Year} +\item{sub_domain}{The name of the subdomain} +\item{value}{The value of the indicator} +... +} + +A data frame with 16,464 rows and 5 variables: +\describe{ +\item{icb22_code}{2022 Integrated Care Board code} +\item{icb22_name}{2022 Integrated Care Board name} +\item{year}{Year} +\item{indicator}{The name of the indicator} +\item{value}{The value of the indicator} +... +} +} +\source{ +\url{https://www.ons.gov.uk/} + +\url{https://www.ons.gov.uk/} +} +\usage{ +england_health_index_ics_indicators + +england_health_index_ics_indicators +} +\description{ +A dataset containing subdomain health index scores for the English Integrated +Care Boards from 2015-2021. + +A dataset containing underlying indicators for the ONS Health Index for +English Integrated Care Boards from 2015-2021. +} +\keyword{datasets} diff --git a/man/england_health_index_subdomains.Rd b/man/england_health_index_subdomains.Rd index d0b1d0c..97788fd 100644 --- a/man/england_health_index_subdomains.Rd +++ b/man/england_health_index_subdomains.Rd @@ -33,7 +33,7 @@ A data frame with 2,149 rows and 16 variables: england_health_index_subdomains } \description{ -A dataset containing overall health index scores for the English lower tier +A dataset containing subdomain health index scores for the English lower tier local authorities from 2015-2021. } \keyword{datasets}