Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First draft completed - cancer-screening #31

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
) |>
Comment on lines +72 to +74
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more succinct way to write this would be to just select() the two columns you need, then you don't need to use relocate():

cancer_screening_hb |>
  left_join(hb_lookup) |>
  select(trust18_code, total_cancer_screening_percentage)

Would achieve the same thing :)

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_exclamation_mark: Data only available as separate conditions (CHD, COPD, Heart Failure 1 & 3, Stroke and TIA) as a rate per 1,000. To be comparable to England's Index must be shown as a %. To review at the end. | :x: |
| Healthy Lives | High Blood Pressure | 2023-24 | [NISRA](https://data.nisra.gov.uk/) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_exclamation_mark: Data only available for raw prevalence rate. Percentage required to best match England's Health Index. | :x: |
| Healthy Lives | Overweight and Obesity in Adults | :x: | :x: | :x: | :x: - Data unavailable. | :x: |
| Healthy Lives | Cancer Screening | 2022/23 | [Public Health](https://www.publichealth.hscni.net/publications/director-public-health-core-tables-2022) | :x:| ❗: - The data (breast, bowel, and cervical cancers) is at the Health and Social Care Trusts level | :x: |
| 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) | :x: | ❗: - The data is at the Health and Social Care Trusts level | :x: |
| Healthy Lives | Children in State Care | :x: | :x: | :x: | ❗: - Indicator not overtly present in England's HI. To review at the end (and likely remove) | :x: |
Expand Down