Skip to content

Commit

Permalink
Merge branch 'main' into cancer-screening
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeJohnPage committed Jan 20, 2025
2 parents 9692bfb + 3ef38c9 commit 9022b6b
Show file tree
Hide file tree
Showing 44 changed files with 1,072 additions and 299 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ po/*~
# RStudio Connect folder
rsconnect/
.Rproj.user
*.xlsx
230 changes: 230 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,43 @@
#'
"lives_gsce_attainment"

#' Percentage of Adults Diagnosed with High Blood Pressure (2023-2024)
#'
#' A dataset containing statistics on percentage of adults diagnosed with high
#' blood pressure, by Council (2023-2024).
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{high_blood_pressure_percentage}{Percentage of adults diagnosed with
#' high blood pressure}
#' \item{year}{Time period - Financial year}
#'
#' ...
#' }
#' @source \url{https://data.nisra.gov.uk/}
"lives_high_blood_pressure"


#' Percentage of People that Eat Healthy (2022-2023)
#'
#' A dataset containing statistics on fruit and vegetable consumption in
#' each Northern Irish Council, 2022-23.
#'
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{healthy_eating_percentage}{Percentage of people that consume
#' 5 portions or more of fruit and vegetable per day}
#' \item{year}{Time period}
#'
#' ...
#' }
#' @source \url{https://www.health-ni.gov.uk/publications/health-survey-northern-ireland-first-results-202223}
#'
"lives_healthy_eating"

#' Percentage of Babies Born Not at a Healthy Birth Weight (2022-2023)
#'
#' A dataset containing percentage babies born not at a healthy birth weight.
Expand Down Expand Up @@ -88,6 +125,23 @@
#'
"lives_childhood_overweight_obesity"

#' Rate of infant mortality (2018-2022)
#'
#' A dataset containing statistics on the rate of infant mortality in each
#' Norther Irish Council, 2018-2022.
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{infant_mortality_per_1k}{Rate of infants per 1,000 that have died
#' under the age of 1}
#' \item{year}{Time period - five year aggregate}
#'
#' ...
#' }
#' @source \url{https://data.nisra.gov.uk/}
"lives_infant_mortality"

#' Percentage of Pupil Absences (2021/22)
#'
#' A dataset containing statistics on the percentage of unauthorised school
Expand All @@ -106,6 +160,23 @@
#'
"lives_pupil_absence"

#' Percentage of Current Smokers (2022-2023)
#'
#' A dataset containing statistics on smoking status in
#' each Northern Irish Council, 2022-23.
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{smoking_percentage}{Percentage of people that are current smokers}
#' \item{year}{Time period}
#'
#' ...
#' }
#' @source \url{https://www.health-ni.gov.uk/publications/health-survey-northern-ireland-first-results-202223}
#'
"lives_smoking"

#' Rates of teenage pregnancies per 1,000 (2020-22)
#'
#' A dataset containing statistics on the rate of teenage pregnancies per 1k.
Expand All @@ -123,6 +194,25 @@
#'
"lives_teenage_pregnancy"

#' Percentage of Childhood Vaccine Coverage (2022-2023)
#'
#' A dataset containing statistics on childhood vaccine coverage (aged 6 and
#' under) in each Northern Irish Council, 2022/23.
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{child_vaccine_coverage_percentage}{Percentage of vaccine coverage. Includes
#' childhood immunisation statistics (DtaP/IPV/Hib(HepB), MenB, Rotavirus, PCV,
#' Hib/MenC, MMR1 (by age 2), MMR1 (by age 5), MMR2 (by age 5). Pre-School Booster)}
#' \item{year}{School Year}
#'
#' ...
#' }
#' @source \url{https://www.publichealth.hscni.net/publications/director-public-health-core-tables-2022}
#'
"lives_child_vaccine_coverage"

#' Percentage of Young People in Education, Employment, and Training (2022/23)
#'
#' A dataset containing statistics on the percentage of young people (aged 16-18)
Expand Down Expand Up @@ -198,6 +288,59 @@
#' @source \url{https://www.ons.gov.uk/datasets/wellbeing-local-authority/editions/time-series/versions/4}
"people_anxiety"

#' Cancer Registrations Percentage (2023-2024)
#'
#' A dataset containing statistics on cancer registration percentages, per
#' Council (2023-2024).
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{cancer_percentage}{Percentage of people with cancer per Council}
#' \item{year}{Time period - Financial year}
#' ...
#' }
#' @source \url{https://data.nisra.gov.uk/}
"people_cancer"

' Percentage of People with Dementia
#'
#' A dataset containing statistics on the percentage of people medically
#' diagnosed with dementia, by Council (2023-24).
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{dementia_percentage}{Percentage of people medically diagnosed with
#' dementia, per Council}
#' \item{year}{Time period - Financial year}
#'
#' ...
#' }
#' @source \url{https://data.nisra.gov.uk/}
"people_dementia"

#' Percentage Rate of Cardiovascular Conditions (CHD, Atrial Fibrillation,
#' Heart Failure, Stroke & TIA) (2023/2024)
#'
#' A dataset containing statistics on the percentage of people who self-reported
#' as having CHD, Atrial Fibrillation, Heart Failure, and/or Stroke & TIA in
#' Northern Irish Council Areas.
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authroity Code}
#' \item{cardiovascular_conditions_percentage}{Percentage of people who self-reported
#' as having CHD, Atrial Fibrillation, Heart Failure, and/or Stroke & TIA}
#' \item{year}{Time period - financial year}
#'
#' ...
#' }
#' @source \url{https://data.nisra.gov.uk/}
#'
"people_cardiovascular_conditions"


#' Percentage of People Aged 15-64 with Long-Term Health Problem/Disability
#' that Limits Daily Activities
#'
Expand Down Expand Up @@ -286,6 +429,77 @@
#' @source \url{https://www.nisra.gov.uk/publications/census-2021-main-statistics-health-disability-and-unpaid-care-tables}
"people_mental_health"

#' Percentage of Households without Internet Access (2021/22)
#'
#' A dataset containing statistics on the percentage of households without
#' internet access in Northern Irish Council Areas.
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{no_internet_access_percentage}{Percentage of households without access
#' to the internet}
#' \item{year}{Financial Year}
#'
#' ...
#' }
#' @source \url{https://data.nisra.gov.uk/}
#'
"places_internet_access"

#' Air pollution (2019)
#'
#' A dataset containing population-weighted annual mean PM2.5 data for 2019, by
#' Northern Irish Council Area. Uses the anthropogenic component.
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{air_pollution_weighted}{Population-weighted annual mean PM2.5}
#' \item{year}{Year}
#'
#' ...
#' }
#' @source \url{https://uk-air.defra.gov.uk/data/pcm-data}
"places_air_pollution"

#' Percentage Household Overcrowding (2017)
#'
#' A dataset containing statistics on the percentage of households experiencing
#' household overcrowding, per Council (2017).
#' Household overcrowding is typically defined as households with an occupancy
#' rating of -1 or lower.
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{household_overcrowding_percentage}{Percentage of households
#' experiencing household overcrowding}
#' \item{year}{Year}
#'
#' ...
#' }
#' @source \url{https://data.nisra.gov.uk/}
"places_household_overcrowding"

#' Percentage Rate of Respiratory Conditions (Asthma and COPD) (2023/2024)
#'
#' A dataset containing statistics on the percentage of people who self-reported
#' as having asthma and/or COPD in Northern Irish Council Areas.
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authroity Code}
#' \item{respiratory_conditions_percentage}{Percentage of people who self-reported
#' as having asthma and/or COPD}
#' \item{year}{Time period - financial year}
#'
#' ...
#' }
#' @source \url{https://data.nisra.gov.uk/}
#'
"people_respiratory_conditions"

#' Rates of Personal Crime per 1,000 (2017)
#'
#' A dataset containing statistics on 'personal crime' per 1,000 people in
Expand All @@ -304,6 +518,22 @@
#'
"places_personal_crime"

#' Road safety (2023)
#'
#' A dataset containing number of people killed or seriously injured in each
#' Northern Irish Council Area in 2023 (latest available data).
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{road_accident_count}{Number of people killed or seriously injured, per Local Authority}
#' \item{year}{Year}
#'
#' ...
#' }
#' @source \url{https://www.psni.police.uk/about-us/our-publications-and-reports/official-statistics/road-traffic-collision-statistics}
"places_road_safety"

#' Rate of Self-Harm Related Admissions per 100,000 (2018/19-2022/23)
#'
#' A dataset containing statistics on the rate of self-harm related admissions
Expand Down
61 changes: 61 additions & 0 deletions data-raw/healthy-lives/healthy-eating.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# ---- Load packages ----
library(tidyverse)
library(readxl)
library(httr)
library(geographr)

# ---- Get and clean data ----
# Healthy Eating Data
# Source: https://www.health-ni.gov.uk/publications/health-survey-northern-ireland-first-results-202223

GET(
"https://www.health-ni.gov.uk/sites/default/files/publications/health/hsni-trend-tables-22-23.xlsx",
write_disk(tf <- tempfile(fileext = ".xlsx"))
)

healthy_eating_raw <- read_excel(tf, sheet = 17, skip = 160)

healthy_eating_hb <- healthy_eating_raw |>
slice(2:6) |>
select(
hb24_name = `All`,
healthy_eating_percentage = `2022/23...14`
)


# Geographical Code Data: Health Board and Local Authority

hb_ltla_lookup <- lookup_ltla21_hsct18 |>
distinct(ltla21_code, trust18_code)

hb_lookup <- boundaries_trusts_ni18 |>
sf::st_drop_geometry()


# Join datasets
# Healthy eating data + Trust name and code

healthy_eating_hb <- healthy_eating_hb |>
select(
trust18_name = hb24_name,
healthy_eating_percentage
) |>
left_join(hb_lookup, by = "trust18_name") |>
select(-trust18_name) |>
relocate(trust18_code)

# Healthy eating data + LA code

lives_healthy_eating <- healthy_eating_hb |>
left_join(hb_ltla_lookup, by = "trust18_code") |>
mutate(year = "2022/23") |>
select(
ltla24_code = ltla21_code,
healthy_eating_percentage,
year
) |>
arrange(ltla24_code) |>
mutate(healthy_eating_percentage = as.numeric(healthy_eating_percentage))

# ---- Save output to data/ folder ----
usethis::use_data(lives_healthy_eating, overwrite = TRUE)
27 changes: 27 additions & 0 deletions data-raw/healthy-lives/high-blood-pressure.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ---- Load packages ----
library(tidyverse)

# ---- Get and clean data ----
# High Blood Pressure Data
# Source: https://data.nisra.gov.uk/

url <- "https://ws-data.nisra.gov.uk/public/api.restful/PxStat.Data.Cube_API.ReadDataset/DISPREVLGD/CSV/1.0/"
high_blood_pressure_raw <- read_csv(url)

lives_high_blood_pressure <- high_blood_pressure_raw |>
filter(
`Statistic Label` == "Raw disease prevalence per 1,000 patients",
`Disease` == "Hypertension",
`Financial Year` == "2023/24",
`LGD2014` != "N92000002"
) |>
rowwise() |>
mutate(high_blood_pressure_percentage = VALUE / 10) |>
select(
ltla24_code = LGD2014,
high_blood_pressure_percentage,
year = `Financial Year`
)

# ---- Save output to data/ folder ----
usethis::use_data(lives_high_blood_pressure, overwrite = TRUE)
Loading

0 comments on commit 9022b6b

Please sign in to comment.