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 - air-pollution #19

Open
wants to merge 1 commit 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
16 changes: 16 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@
#' @source \url{https://www.nisra.gov.uk/publications/census-2021-main-statistics-health-disability-and-unpaid-care-tables}
"people_mental_health"

#' Air pollution (2019)
#'
#' A dataset containing population-weighted annual mean PM2.5 data for 2019, by
#' Northern Irish Council Area. Uses the anthropogenic component.
#'
#' @format A data frame with 11 rows and 3 variables:
#' \describe{
#' \item{ltla24_code}{Local Authority Code}
#' \item{air_pollution_weighted}{Population-weighted annual mean PM2.5}
#' \item{year}{Year}
#'
#' ...
#' }
#' @source \url{https://uk-air.defra.gov.uk/data/pcm-data}
"places_air_pollution"

#' Rates of Personal Crime per 1,000 (2017)
#'
#' A dataset containing statistics on 'personal crime' per 1,000 people in
Expand Down
34 changes: 21 additions & 13 deletions data-raw/healthy-places/air-pollution.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# ---- Load packages ----
library(tidyverse)
library(geographr)

# Lookup
lookup <-
boundaries_lad |>
select(-geometry) |>
st_drop_geometry() |>
filter(str_detect(lad_code, "^N"))
# ---- Get data ----
# LA Codes

ltla_lookup <- lookup_ltla_ltla |>
filter(str_detect(ltla23_code, "N")) |>
select(ltla23_code, ltla23_name)

# Air Pollution
# Source: https://uk-air.defra.gov.uk/data/pcm-data
air_pollution_raw <-
read_csv(
Expand All @@ -19,14 +21,20 @@ air_pollution_raw <-
air_pollution <-
air_pollution_raw |>
select(
lad_name = `Local Authority`,
ltla23_name = `Local Authority`,
air_pollution_weighted = `PM2.5 2019 (anthropogenic)`
)

# Join
air_pollution <-
lookup |>
left_join(air_pollution, by = "lad_name") |>
select(-lad_name)
# Join datasets
places_air_pollution <-
ltla_lookup |>
left_join(air_pollution, by = "ltla23_name") |>
select(
ltla24_code = ltla23_code,
air_pollution_weighted,
-ltla23_name
) |>
mutate(year = "2019")

write_rds(air_pollution, "data/vulnerability/health-inequalities/northern-ireland/healthy-places/air-pollution.rds")
# ---- Save output to data/ folder ----
usethis::use_data(places_air_pollution, overwrite = TRUE)
Binary file added data/places_air_pollution.rda
Binary file not shown.
27 changes: 27 additions & 0 deletions man/places_air_pollution.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 @@ -65,7 +65,7 @@
| Healthy Places | Patients offered acceptable GP practice appointments | :x: | :x: | :x: | :x: Data unavailable. | :x: |
| Healthy Places | Personal Crime | 2017 | [NISRA](https://data.nisra.gov.uk/) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_check_mark: Indicator: Personal crime per 1,000 people. | :heavy_check_mark: |
| Healthy Places | Low-Level Crime | :x: | :x: | :x: | :x: Data unavailable. | :x: |
| Healthy Places | Air Pollution | 2019 | [DEFRA](https://uk-air.defra.gov.uk/data/pcm-data) | [OGL3](https://www.gov.scot/crown-copyright/) | :heavy_check_mark: | :heavy_check_mark: |
| Healthy Places | Air Pollution | 2019 | [DEFRA](https://uk-air.defra.gov.uk/data/pcm-data) | [OGL3](https://www.gov.scot/crown-copyright/) | :heavy_check_mark: Indicator: Air pollution, population weighted annual mean PM2.5 | :heavy_check_mark: |
| Healthy Places | Neighbourhood noise | 2017 | [NISRA](https://www.ninis2.nisra.gov.uk) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_check_mark: | :heavy_check_mark: |
| Healthy Places | Road Safety | :x: | :x: | :x: | :x: - data unavailable | :x: |
| Healthy Places | Road Traffic Volume | :x: | :x: | :x: | :x: TO DO | :x: |
Expand Down