Skip to content

Commit

Permalink
Merge pull request #31 from humaniverse/cancer-screening
Browse files Browse the repository at this point in the history
First draft completed - cancer-screening
  • Loading branch information
MikeJohnPage authored Jan 20, 2025
2 parents 3ef38c9 + 9022b6b commit 488584b
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 1 deletion.
19 changes: 19 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#' Percentage of Cancer Screening Uptake (2022-2023)
#'
#' A dataset containing statistics on the percentage of cancer screening uptake
#' in each Northern Irish Council, 2022-2023.
#'
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{cancer_screening_uptake}{Percentage of cancer screening uptake; breast,
#' bowel, and cervical cancer.}
#' \item{year}{Time period}
#'
#' ...
#' }
#' @source \url{https://www.publichealth.hscni.net/publications/director-public-health-core-tables-2022}
#'
"lives_cancer_screening"

#' Percentage of Absolute Child Poverty (2017)
#'
#' A dataset containing statistics on the percentage of children (aged 15 and
Expand Down
89 changes: 89 additions & 0 deletions data-raw/healthy-lives/cancer-screening.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# ---- Load packages ----
library(tidyverse)
library(httr)
library(readxl)
library(geographr)

# ---- Get and clean data ----
# 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()

# Cancer Screening data
# Source: https://www.publichealth.hscni.net/publications/director-public-health-core-tables-2022

GET(
"https://www.publichealth.hscni.net/sites/default/files/2024-04/Core%20Tables%202022%20-%20Excel%20tables_1.xlsx",
write_disk(tf <- tempfile(fileext = ".xlsx"))
)


# Cervical Cancer
cervical_raw <- read_excel(tf, sheet = 34, skip = 3)

cervical_hb <- cervical_raw |>
slice(1:5) |>
select(
trust18_name = HSCT,
cervical_screening_percentage = `% Coverage`
)


# Breast Cancer
breast_raw <- read_excel(tf, sheet = 35, skip = 3)

breast_hb <- breast_raw |>
slice(1:5) |>
select(
trust18_name = `HSC Trust of residence`,
breast_screening_percentage = `%`
)


# Bowel Cancer
bowel_raw <- read_excel(tf, sheet = 37, skip = 3)

bowel_hb <- bowel_raw |>
slice(1:5) |>
select(
trust18_name = `HSCT`,
bowel_screening_percentage = `Uptake for bowel cancer screening \r\n(%)`
)

# Join datasets
# Cancer Screening Percentages

cancer_screening_hb <- cervical_hb |>
left_join(breast_hb) |>
left_join(bowel_hb) |>
rowwise() |>
mutate(
total_cancer_screening_percentage = mean(c_across(c(cervical_screening_percentage, breast_screening_percentage, bowel_screening_percentage)), na.rm = TRUE)
) |>
ungroup()

# Cancer screening data + Trust name and code
cancer_screening_hb <- cancer_screening_hb |>
left_join(hb_lookup) |>
select(
-trust18_name, -cervical_screening_percentage, -breast_screening_percentage, -bowel_screening_percentage
) |>
relocate(trust18_code)

# Cancer screening data + LA code
lives_cancer_screening <- cancer_screening_hb |>
left_join(hb_ltla_lookup) |>
mutate(year = "2022-23") |>
select(
ltla24_code = ltla21_code,
cancer_screening_uptake = total_cancer_screening_percentage,
year
) |>
arrange(ltla24_code)

# ---- Save output to data/ folder ----
usethis::use_data(lives_cancer_screening, overwrite = TRUE)
Binary file added data/lives_cancer_screening.rda
Binary file not shown.
28 changes: 28 additions & 0 deletions man/lives_cancer_screening.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
| Healthy Lives |Cardiovascular Conditions | 2023/24 | [NISRA](https://data.nisra.gov.uk/k) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_check_mark: Indicator: Percentage rate of people self-reported as having CHD, Atrial Fibrillation, Heart Failure, and/or Stroke & TIA. | :heavy_check_mark: |
| Healthy Lives | High Blood Pressure | 2023-24 | [NISRA](https://data.nisra.gov.uk/) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_check_mark: Indicator: Percentage of adults with high blood pressure | :heavy_check_mark: |
| Healthy Lives | Overweight and Obesity in Adults | :x: | :x: | :x: | :x: - Data unavailable. | :x: |
| Healthy Lives | Cancer Screening | 2023-24 | [NISRA](https://data.nisra.gov.uk/) | [OGL3](https://www.nisra.gov.uk/crown-copyright) | :heavy_check_mark: Indicator: Percentage of people with cancer| :heavy_check_mark: |
| Healthy Lives | Cancer Screening | 2022/23 | [Public Health](https://www.publichealth.hscni.net/publications/director-public-health-core-tables-2022) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx)| heavy_check_mark: Indicator: Percentage of bowel, breast, and cervical cancer screening uptake. | :heavy_check_mark: |
| Healthy Lives | Sexual Health | :x: | :x: | :x: | :x: - Data unavailable. | :x: |
| Healthy Lives | Vaccination Coverage | 2022/23 | [Public Health](https://www.publichealth.hscni.net/publications/director-public-health-core-tables-2022) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_check_mark: Indicator: Percentage of vaccine coverage in children 6 and under | :heavy_check_mark: |

Expand Down

0 comments on commit 488584b

Please sign in to comment.