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 - smoking #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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 Down
54 changes: 54 additions & 0 deletions data-raw/healthy-lives/smoking.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ---- Load packages ----
library(tidyverse)
library(readxl)
library(httr)
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()


# 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"))
)

smoking_raw <- read_excel(tf, sheet = 19, skip = 166)

smoking_hb <- smoking_raw |>
slice(2:6) |>
select(
trust18_name = `All`,
smoking_percentage = `2022/23...14`
)

# Join datasets
# Smoking data + Trust name and code

smoking_hb <- smoking_hb |>
left_join(hb_lookup) |>
select(-trust18_name) |>
relocate(trust18_code)

# Smoking data + LA code
lives_smoking <- smoking_hb |>
left_join(hb_ltla_lookup) |>
mutate(year = "2022/23") |>
select(
ltla24_code = ltla21_code,
smoking_percentage,
year
) |>
arrange(ltla24_code)

# ---- Save output to data/ folder ----
usethis::use_data(lives_smoking, overwrite = TRUE)
Binary file added data/lives_smoking.rda
Binary file not shown.
27 changes: 27 additions & 0 deletions man/lives_smoking.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 @@ -7,7 +7,7 @@
| Healthy Lives | Healthy Eating | 2022-23 | [Health Survey Northern Ireland](https://www.health-ni.gov.uk/publications/health-survey-northern-ireland-first-results-202223) | :x: | :heavy_exclamation_mark: - The data is at the Health and Social Care Trusts level | :x: |
| Healthy Lives | Physical Activity | :x: | :x: | :x:| :x: Data not collected. | :x: |
| Healthy Lives | Sedentary Behaviour | :x: | :x: | :x:| :x: - Data unavailable | :x: |
| Healthy Lives | Smoking | 2022-23 | [Health Survey Northern Ireland](https://www.health-ni.gov.uk/publications/health-survey-northern-ireland-first-results-202223) | :x: | :heavy_exclamation_mark: - The data is at the Health and Social Care Trusts level | :x: |
| Healthy Lives | Smoking | 2022-23 | [Health Survey Northern Ireland](https://www.health-ni.gov.uk/publications/health-survey-northern-ireland-first-results-202223) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_check_mark: Indicator: Percentage of people that are current smokers | :heavy_check_mark: |
| Healthy Lives | Early Years Development | NA | [NISRA](https://datavis.nisra.gov.uk/dissemination/NINIS-redirect.html) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_exclamation_mark: Data unavailable - contact statistics@education-ni.gov.uk | :x: |
| Healthy Lives | Pupil Absence | 2021/22 | [NISRA](https://data.nisra.gov.uk/) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_check_mark: Indicator: Percentage of unauthorised school absences| :heavy_check_mark: |
| Healthy Lives | GCSE Achievement | 2022-23 | [NISRA](https://data.nisra.gov.uk/) | [NISRA](https://data.nisra.gov.uk/) | :heavy_check_mark: Indicator: Percentage of GSCE attainment, including Maths and English (Grades A-C) | :heavy_check_mark: |
Expand Down