diff --git a/R/data.R b/R/data.R index 793b2da..dad075c 100644 --- a/R/data.R +++ b/R/data.R @@ -319,6 +319,22 @@ #' "places_personal_crime" +#' Road safety (2023) +#' +#' A dataset containing number of people killed or seriously injured in each +#' Northern Irish Council Area in 2023 (latest available data). +#' +#' @format A data frame with 11 rows and 3 variables: +#' \describe{ +#' \item{ltla24_code}{Local Authority Code} +#' \item{road_accident_count}{Number of people killed or seriously injured, per Local Authority} +#' \item{year}{Year} +#' +#' ... +#' } +#' @source \url{https://www.psni.police.uk/about-us/our-publications-and-reports/official-statistics/road-traffic-collision-statistics} +"places_road_safety" + #' Rate of Self-Harm Related Admissions per 100,000 (2018/19-2022/23) #' #' A dataset containing statistics on the rate of self-harm related admissions diff --git a/data-raw/healthy-places/road-safety.R b/data-raw/healthy-places/road-safety.R new file mode 100644 index 0000000..45d2f41 --- /dev/null +++ b/data-raw/healthy-places/road-safety.R @@ -0,0 +1,51 @@ +# ---- Load packages ---- +library(tidyverse) +library(geographr) +library(readxl) + +# ---- Get data and clean ---- +# LA Codes +ltla_lookup <- lookup_ltla_ltla |> + filter(str_detect(ltla23_code, "N")) |> + select(ltla23_code, ltla23_name) + +# Road Safety Data +# Source: https://www.psni.police.uk/about-us/our-publications-and-reports/official-statistics/road-traffic-collision-statistics + +url <- "https://www.psni.police.uk/sites/default/files/2024-03/2023%20Key%20Statistics%20tables.xlsx" +temp_file <- tempfile(fileext = ".xlsx") +download.file(url, temp_file, mode = "wb") + +road_safety_raw <- read_excel(temp_file, sheet = 6, skip = 5) + +road_safety <- road_safety_raw |> + select( + ltla23_name = `Area`, + accident_count = `Total...11` + ) |> + slice(1:11) |> + mutate( + ltla23_name = ltla23_name |> + str_replace_all("&", "and") |> + str_replace_all("Belfast City", "Belfast") |> + str_replace_all("Lisburn & Castlereagh City", "Lisburn and Castlereagh") + ) + +# Join datasets +places_road_safety <- ltla_lookup |> + left_join(road_safety, by = "ltla23_name") |> + mutate( + accident_count = case_when( + is.na(accident_count) & ltla23_code == "N09000007" ~ 615, + TRUE ~ accident_count + ), + year = "2023" + ) |> + select( + ltla24_code = ltla23_code, + road_accident_count = accident_count, + year + ) + +# ---- Save output to data/ folder ---- +usethis::use_data(places_road_safety, overwrite = TRUE) diff --git a/data/places_road_safety.rda b/data/places_road_safety.rda new file mode 100644 index 0000000..f2957da Binary files /dev/null and b/data/places_road_safety.rda differ diff --git a/man/places_road_safety.Rd b/man/places_road_safety.Rd new file mode 100644 index 0000000..6db758a --- /dev/null +++ b/man/places_road_safety.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{places_road_safety} +\alias{places_road_safety} +\title{Road safety (2023)} +\format{ +A data frame with 11 rows and 3 variables: +\describe{ +\item{ltla24_code}{Local Authority Code} +\item{road_accident_count}{Number of people killed or seriously injured, per Local Authority} +\item{year}{Year} + +... +} +} +\source{ +\url{https://www.psni.police.uk/about-us/our-publications-and-reports/official-statistics/road-traffic-collision-statistics} +} +\usage{ +places_road_safety +} +\description{ +A dataset containing number of people killed or seriously injured in each +Northern Irish Council Area in 2023 (latest available data). +} +\keyword{datasets} diff --git a/metadata.md b/metadata.md index 2518821..d0b8769 100644 --- a/metadata.md +++ b/metadata.md @@ -67,7 +67,7 @@ | 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 | Noise Complaints | 2024 | [DAERA](https://www.daera-ni.gov.uk/sites/default/files/publications/daera/Noise%20Complaint%20Statistics%20for%20NI%202023-24.PDF) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_exclamation_mark: Raw data currently unavailable (only in a report). UPDATE: Now contacted aeqteam@daera-ni.gov.uk and asked for raw data in Figure 1 of report (9.1.25) | :heavy_exclamation_mark: | -| Healthy Places | Road Safety | :x: | :x: | :x: | :x: - data unavailable | :x: | +| Healthy Places | Road Safety | 2023 | [PSNI](https://www.psni.police.uk/about-us/our-publications-and-reports/official-statistics/road-traffic-collision-statistics)| [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_check_mark: Number of people seriously injured or killed by Local Authority area. | :heavy_check_mark: | | Healthy Places | Road Traffic Volume | :x: | :x: | :x: | :x: TO DO | :x: | | Healthy Places | Internet access | 2021/22 | [NISRA](https://data.nisra.gov.uk/) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_check_mark: Indicator: Percentage of households without access to the internet at home. | :heavy_check_mark:| | Healthy Places | Transport noise: Daytime | 2017 | [NISRA](https://www.ninis2.nisra.gov.uk) | [OGL3](https://www.ninis2.nisra.gov.uk/public/terms.aspx) | :heavy_check_mark: - Separate data was not available for day & night, so just one metric has been used | :heavy_check_mark: |