-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into cancer-screening
- Loading branch information
Showing
44 changed files
with
1,072 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,4 @@ po/*~ | |
# RStudio Connect folder | ||
rsconnect/ | ||
.Rproj.user | ||
*.xlsx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.