diff --git a/R/data.R b/R/data.R index 5968887..5fdc27b 100644 --- a/R/data.R +++ b/R/data.R @@ -93,6 +93,23 @@ NULL #' @source \url{https://www.england.nhs.uk/} "england_critical_general_acute_beds" +#' Disability by LTLA for England, 2021 +#' +#' A dataset containing LTLA data on numbers disabled under the Equality Act. +#' +#' @format A data frame with 662 rows and 5 variables: +#' \describe{ +#' \item{ltla21_code}{LTLA code} +#' \item{total_residents}{Total residents in the local authority} +#' \item{disability_level}{Disabled or Not disabled under the Equality Act} +#' \item{n}{number of people} +#' \item{prop}{proportion of people} + +#' ... +#' } +#' @source \url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +"england_disability_21" + #' Hospital ICB Discharge Data - Criteria to Reside #' #' A dataset containing NHS Integrated Care Board discharge data on how many @@ -220,6 +237,37 @@ NULL #' @source \url{https://www.ons.gov.uk/} "england_health_index_indicators" +#' Legal Partnership Status, England, 2021 +#' +#' A dataset containing legal partnership status data at LTLA level +#' +#' @format A data frame with 5,627 rows and 5 variables: +#' \describe{ +#' \item{ltla21_code}{LTLA code} +#' \item{total_population}{Population in the LTLA} +#' \item{legal_partnership}{Type of legal partnership} +#' \item{n}{Number of people} +#' \item{prop}{Percentage} +#' } +#' @source \url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +"england_legal_partnership_21" + +#' Sexual orientation, England, 2021 +#' +#' A dataset containing sexual orientation data at LTLA level +#' +#' @format A data frame with 1,655 rows and 5 variables: +#' \describe{ +#' \item{ltla21_code}{LTLA code} +#' \item{total_residents}{Residents in the LTLA} +#' \item{sexual_orientation}{Sexual orientation} +#' \item{n}{Number of people} +#' \item{prop}{Percentage} +#' } +#' @source \url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +"england_sexual_orientation_21" + + #' Psychological Therapies - IAPT #' #' A dataset containing NHS Sub Integrated Care Board (formerly CCGs) data. @@ -472,6 +520,23 @@ NULL #' @source \url{https://www.opendata.nhs.scot/} "scotland_rtt_hb" + +#' Disability by LTLA for Wales, 2021 +#' +#' A dataset containing LTLA data on numbers disabled under the Equality Act. +#' +#' @format A data frame: +#' \describe{ +#' \item{ltla21_code}{LTLA code} +#' \item{total_residents}{Total residents in the local authority} +#' \item{disability_level}{Disabled or Not disabled under the Equality Act} +#' \item{n}{number of people} +#' \item{prop}{proportion of people} + +#' ... +#' } +#' @source \url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +"wales_disability_21" #' Homelessness in Scotland #' #' A dataset containing statistics on households assessed as homeless and @@ -565,6 +630,35 @@ NULL #' @source \url{https://statswales.gov.wales/} "wales_hospitals_critical_general_acute_beds" +#' Legal Partnership Status, Wales, 2021 +#' +#' A dataset containing legal partnership status data at LTLA level +#' +#' @format A data frame: +#' \describe{ +#' \item{ltla21_code}{LTLA code} +#' \item{total_population}{Population in the LTLA} +#' \item{legal_partnership}{Type of legal partnership} +#' \item{n}{Number of people} +#' \item{prop}{Percentage} +#' } +#' @source \url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +"wales_legal_partnership_21" + +#' Sexual orientation, Wales, 2021 +#' +#' A dataset containing sexual orientation data at LTLA level +#' +#' @format A data frame: +#' \describe{ +#' \item{ltla21_code}{LTLA code} +#' \item{total_residents}{Residents in the LTLA} +#' \item{sexual_orientation}{Sexual orientation} +#' \item{n}{Number of people} +#' \item{prop}{Percentage} +#' } +#' @source \url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +"wales_sexual_orientation_21" #' Homelessness in Wales #' #' A dataset containing statistics on households assessed as homeless and diff --git a/R/sysdata.rda b/R/sysdata.rda index c6d0861..3a098a0 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/data-raw/england-wales-disability-ltla.R b/data-raw/england-wales-disability-ltla.R new file mode 100644 index 0000000..622d35e --- /dev/null +++ b/data-raw/england-wales-disability-ltla.R @@ -0,0 +1,47 @@ +# ---- Load libs ---- +library(tidyverse) +library(geographr) +library(devtools) +library(httr2) + +# ---- Load internal sysdata.rda file with URLs ---- +load_all(".") + +# ---- Download data ---- +query_url <- + query_urls |> + filter(id == "england_disability_2021") |> + pull(query) + +download <- tempfile(fileext = ".zip") + +request(query_url) |> + req_perform(download) + +unzip(download, exdir = tempdir()) + +list.files(tempdir()) + +raw <- read_csv(file.path(tempdir(), "census2021-ts038-ltla.csv")) + +names(raw) <- str_remove(names(raw), "Disability: ") + +# ---- Detailed ethnic categories ---- +disability_21 <- + raw |> + select( + ltla21_code = `geography code`, + total_residents = `Total: All usual residents`, !contains(":"), -date, -geography + ) |> + pivot_longer(cols = -c(ltla21_code, total_residents), names_to = "disability_level", values_to = "n") |> + mutate(prop = n / total_residents) + +england_disability_21 <- disability_21 |> + filter(str_detect(ltla21_code, "^E")) + +wales_disability_21 <- disability_21 |> + filter(str_detect(ltla21_code, "^W")) + +# ---- Save output to data/ folder ---- +usethis::use_data(england_disability_21, overwrite = TRUE) +usethis::use_data(wales_disability_21, overwrite = TRUE) diff --git a/data-raw/england-wales-legal-partnership-ltla.R b/data-raw/england-wales-legal-partnership-ltla.R new file mode 100644 index 0000000..39e70d4 --- /dev/null +++ b/data-raw/england-wales-legal-partnership-ltla.R @@ -0,0 +1,50 @@ +# ---- Load libs ---- +library(tidyverse) +library(geographr) +library(devtools) +library(httr2) + +# ---- Load internal sysdata.rda file with URLs ---- +load_all(".") + +# ---- Download data ---- +query_url <- + query_urls |> + filter(id == "legal_partnership_status_2021") |> + pull(query) + +download <- tempfile(fileext = ".zip") + +request(query_url) |> + req_perform(download) + +unzip(download, exdir = tempdir()) + +list.files(tempdir()) + +raw <- read_csv(file.path(tempdir(), "census2021-ts002-ltla.csv")) + +names(raw) <- str_remove(names(raw), "Marital and civil partnership status: ") + +# ---- Detailed ethnic categories ---- +legal_partnership_21 <- + raw |> + select(-date, -geography) |> + rename( + ltla21_code = `geography code`, + total_population = `Total; measures: Value` + ) |> + pivot_longer(cols = -c(ltla21_code, total_population), names_to = "legal_partnership", values_to = "n") |> + mutate(prop = n / total_population) |> + mutate(prop = format(prop, scientific = FALSE)) + +england_legal_partnership_21 <- legal_partnership_21 |> + filter(str_detect(ltla21_code, "^E")) + +wales_legal_partnership_21 <- legal_partnership_21 |> + filter(str_detect(ltla21_code, "^W")) + +# ---- Save output to data/ folder ---- +usethis::use_data(england_legal_partnership_21, overwrite = TRUE) +usethis::use_data(wales_legal_partnership_21, overwrite = TRUE) + diff --git a/data-raw/england-wales-sexual-orientation-ltla.R b/data-raw/england-wales-sexual-orientation-ltla.R new file mode 100644 index 0000000..176b80a --- /dev/null +++ b/data-raw/england-wales-sexual-orientation-ltla.R @@ -0,0 +1,49 @@ +# ---- Load libs ---- +library(tidyverse) +library(geographr) +library(devtools) +library(httr2) + +# ---- Load internal sysdata.rda file with URLs ---- +load_all(".") + +# ---- Download data ---- +query_url <- + query_urls |> + filter(id == "sexual_orientation_2021") |> + pull(query) + +download <- tempfile(fileext = ".zip") + +request(query_url) |> + req_perform(download) + +unzip(download, exdir = tempdir()) + +list.files(tempdir()) + +raw <- read_csv(file.path(tempdir(), "census2021-ts077-ltla.csv")) + +names(raw) <- str_remove(names(raw), "Sexual orientation: ") + +# ---- Detailed ethnic categories ---- +sexual_orientation_21 <- + raw |> + select(-date, -geography) |> + rename( + ltla21_code = `geography code`, + total_residents = `Total: All usual residents aged 16 years and over` + ) |> + pivot_longer(cols = -c(ltla21_code, total_residents), names_to = "sexual_orientation", values_to = "n") |> + mutate(prop = n / total_residents) |> + mutate(prop = format(prop, scientific = FALSE)) + +england_sexual_orientation_21 <- sexual_orientation_21 |> + filter(str_detect(ltla21_code, "^E")) + +wales_sexual_orientation_21 <- sexual_orientation_21 |> + filter(str_detect(ltla21_code, "^W")) + +# ---- Save output to data/ folder ---- +usethis::use_data(england_sexual_orientation_21, overwrite = TRUE) +usethis::use_data(wales_sexual_orientation_21, overwrite = TRUE) diff --git a/data-raw/query-urls.R b/data-raw/query-urls.R index 23cbe11..843c005 100644 --- a/data-raw/query-urls.R +++ b/data-raw/query-urls.R @@ -60,6 +60,7 @@ query_urls <- "Critical care and General & Acute Beds – Urgent and Emergency Care Daily Situation Reports", "nhs_critical_general_acute_beds_october_23", "October 2023", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2023/11/202310-October-2023-sitrep-data-FINAL.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/bed-availability-and-occupancy/critical-care-and-general-acute-beds-urgent-and-emergency-care-daily-situation-reports/critical-care-and-general-acute-beds-urgent-and-emergency-care-daily-situation-reports-2023-24/", "Critical care and General & Acute Beds – Urgent and Emergency Care Daily Situation Reports", "nhs_critical_general_acute_beds_november_23", "November 2023", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2023/12/202311-November-2023-sitrep-data-FINAL.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/bed-availability-and-occupancy/critical-care-and-general-acute-beds-urgent-and-emergency-care-daily-situation-reports/critical-care-and-general-acute-beds-urgent-and-emergency-care-daily-situation-reports-2023-24/", "Critical care and General & Acute Beds – Urgent and Emergency Care Daily Situation Reports", "nhs_critical_general_acute_beds_december_23", "December 2023", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2024/01/202312-December-2023-sitrep-data-FINAL.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/bed-availability-and-occupancy/critical-care-and-general-acute-beds-urgent-and-emergency-care-daily-situation-reports/critical-care-and-general-acute-beds-urgent-and-emergency-care-daily-situation-reports-2023-24/", + "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", "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", @@ -84,7 +85,9 @@ query_urls <- "Hospital discharge (criteria to reside)", "nhs_hospital_discharge_data_october_23", "October 2023", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2023/11/Daily-discharge-sitrep-monthly-data-webfile-October2023.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/discharge-delays-acute-data/", "Hospital discharge (criteria to reside)", "nhs_hospital_discharge_data_november_23", "November 2023", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2023/12/Daily-discharge-sitrep-monthly-data-webfile-November2023.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/discharge-delays-acute-data/", "Hospital discharge (criteria to reside)", "nhs_hospital_discharge_data_december_23", "December 2023", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2024/01/Daily-discharge-sitrep-monthly-data-webfile-December2023.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/discharge-delays-acute-data/", + "Legal partnership status", "legal_partnership_status_2021", "2021", "OGLv3", "https://www.nomisweb.co.uk/output/census/2021/census2021-ts002.zip", "https://www.nomisweb.co.uk/sources/census_2021_bulk", "Psychological Therapies (IAPT)", "nhs_iapt_22_23", "January 2022-23", "OGLv3", "https://files.digital.nhs.uk/89/B4C209/iapt_time_series_Jan_22_Jan_23_key_measures.zip", "https://digital.nhs.uk/data-and-information/publications/statistical/psychological-therapies-report-on-the-use-of-iapt-services", + "Sexual orientation", "sexual_orientation_2021", "2021", "OGLv3", "https://www.nomisweb.co.uk/output/census/2021/census2021-ts077.zip", "https://www.nomisweb.co.uk/sources/census_2021_bulk", # Northern Ireland "Bed availability", "ni_beds_pre22", "2013 - 2022", "OGLv3", "https://www.health-ni.gov.uk/sites/default/files/publications/health/hs-inpatient-hts-tables-21-22.csv", "https://www.health-ni.gov.uk/publications/hospital-statistics-inpatient-and-day-case-activity-202122", diff --git a/data/england_disability_21.rda b/data/england_disability_21.rda new file mode 100644 index 0000000..c8a6a1d Binary files /dev/null and b/data/england_disability_21.rda differ diff --git a/data/england_legal_partnership_21.rda b/data/england_legal_partnership_21.rda new file mode 100644 index 0000000..94aa2d9 Binary files /dev/null and b/data/england_legal_partnership_21.rda differ diff --git a/data/england_sexual_orientation_21.rda b/data/england_sexual_orientation_21.rda new file mode 100644 index 0000000..bac73f2 Binary files /dev/null and b/data/england_sexual_orientation_21.rda differ diff --git a/data/wales_disability_21.rda b/data/wales_disability_21.rda new file mode 100644 index 0000000..d70c1e6 Binary files /dev/null and b/data/wales_disability_21.rda differ diff --git a/data/wales_legal_partnership_21.rda b/data/wales_legal_partnership_21.rda new file mode 100644 index 0000000..d2e3b26 Binary files /dev/null and b/data/wales_legal_partnership_21.rda differ diff --git a/data/wales_sexual_orientation_21.rda b/data/wales_sexual_orientation_21.rda new file mode 100644 index 0000000..7b6260f Binary files /dev/null and b/data/wales_sexual_orientation_21.rda differ diff --git a/man/england_disability_21.Rd b/man/england_disability_21.Rd new file mode 100644 index 0000000..27978bf --- /dev/null +++ b/man/england_disability_21.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{england_disability_21} +\alias{england_disability_21} +\title{Disability by LTLA for England, 2021} +\format{ +A data frame with 662 rows and 5 variables: +\describe{ +\item{ltla21_code}{LTLA code} +\item{total_residents}{Total residents in the local authority} +\item{disability_level}{Disabled or Not disabled under the Equality Act} +\item{n}{number of people} +\item{prop}{proportion of people} +... +} +} +\source{ +\url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +} +\usage{ +england_disability_21 +} +\description{ +A dataset containing LTLA data on numbers disabled under the Equality Act. +} +\keyword{datasets} diff --git a/man/england_legal_partnership_21.Rd b/man/england_legal_partnership_21.Rd new file mode 100644 index 0000000..690401a --- /dev/null +++ b/man/england_legal_partnership_21.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{england_legal_partnership_21} +\alias{england_legal_partnership_21} +\title{Legal Partnership Status, England, 2021} +\format{ +A data frame with 5,627 rows and 5 variables: +\describe{ +\item{ltla21_code}{LTLA code} +\item{total_population}{Population in the LTLA} +\item{legal_partnership}{Type of legal partnership} +\item{n}{Number of people} +\item{prop}{Percentage} +} +} +\source{ +\url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +} +\usage{ +england_legal_partnership_21 +} +\description{ +A dataset containing legal partnership status data at LTLA level +} +\keyword{datasets} diff --git a/man/england_sexual_orientation_21.Rd b/man/england_sexual_orientation_21.Rd new file mode 100644 index 0000000..e32f8cf --- /dev/null +++ b/man/england_sexual_orientation_21.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{england_sexual_orientation_21} +\alias{england_sexual_orientation_21} +\title{Sexual orientation, England, 2021} +\format{ +A data frame with 1,655 rows and 5 variables: +\describe{ +\item{ltla21_code}{LTLA code} +\item{total_residents}{Residents in the LTLA} +\item{sexual_orientation}{Sexual orientation} +\item{n}{Number of people} +\item{prop}{Percentage} +} +} +\source{ +\url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +} +\usage{ +england_sexual_orientation_21 +} +\description{ +A dataset containing sexual orientation data at LTLA level +} +\keyword{datasets} diff --git a/man/wales_disability_21.Rd b/man/wales_disability_21.Rd new file mode 100644 index 0000000..6cfd2ca --- /dev/null +++ b/man/wales_disability_21.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{wales_disability_21} +\alias{wales_disability_21} +\title{Disability by LTLA for Wales, 2021} +\format{ +A data frame: +\describe{ +\item{ltla21_code}{LTLA code} +\item{total_residents}{Total residents in the local authority} +\item{disability_level}{Disabled or Not disabled under the Equality Act} +\item{n}{number of people} +\item{prop}{proportion of people} +... +} +} +\source{ +\url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +} +\usage{ +wales_disability_21 +} +\description{ +A dataset containing LTLA data on numbers disabled under the Equality Act. +} +\keyword{datasets} diff --git a/man/wales_legal_partnership_21.Rd b/man/wales_legal_partnership_21.Rd new file mode 100644 index 0000000..53d12a5 --- /dev/null +++ b/man/wales_legal_partnership_21.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{wales_legal_partnership_21} +\alias{wales_legal_partnership_21} +\title{Legal Partnership Status, Wales, 2021} +\format{ +A data frame: +\describe{ +\item{ltla21_code}{LTLA code} +\item{total_population}{Population in the LTLA} +\item{legal_partnership}{Type of legal partnership} +\item{n}{Number of people} +\item{prop}{Percentage} +} +} +\source{ +\url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +} +\usage{ +wales_legal_partnership_21 +} +\description{ +A dataset containing legal partnership status data at LTLA level +} +\keyword{datasets} diff --git a/man/wales_sexual_orientation_21.Rd b/man/wales_sexual_orientation_21.Rd new file mode 100644 index 0000000..2edf592 --- /dev/null +++ b/man/wales_sexual_orientation_21.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{wales_sexual_orientation_21} +\alias{wales_sexual_orientation_21} +\title{Sexual orientation, Wales, 2021} +\format{ +A data frame: +\describe{ +\item{ltla21_code}{LTLA code} +\item{total_residents}{Residents in the LTLA} +\item{sexual_orientation}{Sexual orientation} +\item{n}{Number of people} +\item{prop}{Percentage} +} +} +\source{ +\url{https://www.nomisweb.co.uk/sources/census_2021_bulk} +} +\usage{ +wales_sexual_orientation_21 +} +\description{ +A dataset containing sexual orientation data at LTLA level +} +\keyword{datasets}