diff --git a/R/data.R b/R/data.R index 327711a..9e7075f 100644 --- a/R/data.R +++ b/R/data.R @@ -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. diff --git a/data-raw/healthy-lives/smoking.R b/data-raw/healthy-lives/smoking.R new file mode 100644 index 0000000..0ba0ce5 --- /dev/null +++ b/data-raw/healthy-lives/smoking.R @@ -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) diff --git a/data/lives_smoking.rda b/data/lives_smoking.rda new file mode 100644 index 0000000..7204e69 Binary files /dev/null and b/data/lives_smoking.rda differ diff --git a/man/lives_smoking.Rd b/man/lives_smoking.Rd new file mode 100644 index 0000000..945249b --- /dev/null +++ b/man/lives_smoking.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{lives_smoking} +\alias{lives_smoking} +\title{Percentage of Current Smokers (2022-2023)} +\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} +} +\usage{ +lives_smoking +} +\description{ +A dataset containing statistics on smoking status in +each Northern Irish Council, 2022-23. +} +\keyword{datasets} diff --git a/metadata.md b/metadata.md index 63f9025..23cb8cb 100644 --- a/metadata.md +++ b/metadata.md @@ -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: |