Skip to content

Commit d48f6ee

Browse files
authored
Merge pull request #20 from humaniverse/road-safety
First draft completed - road-safety
2 parents c2eb044 + fa79689 commit d48f6ee

File tree

5 files changed

+95
-1
lines changed

5 files changed

+95
-1
lines changed

R/data.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,22 @@
319319
#'
320320
"places_personal_crime"
321321

322+
#' Road safety (2023)
323+
#'
324+
#' A dataset containing number of people killed or seriously injured in each
325+
#' Northern Irish Council Area in 2023 (latest available data).
326+
#'
327+
#' @format A data frame with 11 rows and 3 variables:
328+
#' \describe{
329+
#' \item{ltla24_code}{Local Authority Code}
330+
#' \item{road_accident_count}{Number of people killed or seriously injured, per Local Authority}
331+
#' \item{year}{Year}
332+
#'
333+
#' ...
334+
#' }
335+
#' @source \url{https://www.psni.police.uk/about-us/our-publications-and-reports/official-statistics/road-traffic-collision-statistics}
336+
"places_road_safety"
337+
322338
#' Rate of Self-Harm Related Admissions per 100,000 (2018/19-2022/23)
323339
#'
324340
#' A dataset containing statistics on the rate of self-harm related admissions

data-raw/healthy-places/road-safety.R

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# ---- Load packages ----
2+
library(tidyverse)
3+
library(geographr)
4+
library(readxl)
5+
6+
# ---- Get data and clean ----
7+
# LA Codes
8+
ltla_lookup <- lookup_ltla_ltla |>
9+
filter(str_detect(ltla23_code, "N")) |>
10+
select(ltla23_code, ltla23_name)
11+
12+
# Road Safety Data
13+
# Source: https://www.psni.police.uk/about-us/our-publications-and-reports/official-statistics/road-traffic-collision-statistics
14+
15+
url <- "https://www.psni.police.uk/sites/default/files/2024-03/2023%20Key%20Statistics%20tables.xlsx"
16+
temp_file <- tempfile(fileext = ".xlsx")
17+
download.file(url, temp_file, mode = "wb")
18+
19+
road_safety_raw <- read_excel(temp_file, sheet = 6, skip = 5)
20+
21+
road_safety <- road_safety_raw |>
22+
select(
23+
ltla23_name = `Area`,
24+
accident_count = `Total...11`
25+
) |>
26+
slice(1:11) |>
27+
mutate(
28+
ltla23_name = ltla23_name |>
29+
str_replace_all("&", "and") |>
30+
str_replace_all("Belfast City", "Belfast") |>
31+
str_replace_all("Lisburn & Castlereagh City", "Lisburn and Castlereagh")
32+
)
33+
34+
# Join datasets
35+
places_road_safety <- ltla_lookup |>
36+
left_join(road_safety, by = "ltla23_name") |>
37+
mutate(
38+
accident_count = case_when(
39+
is.na(accident_count) & ltla23_code == "N09000007" ~ 615,
40+
TRUE ~ accident_count
41+
),
42+
year = "2023"
43+
) |>
44+
select(
45+
ltla24_code = ltla23_code,
46+
road_accident_count = accident_count,
47+
year
48+
)
49+
50+
# ---- Save output to data/ folder ----
51+
usethis::use_data(places_road_safety, overwrite = TRUE)

data/places_road_safety.rda

319 Bytes
Binary file not shown.

man/places_road_safety.Rd

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

metadata.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
| 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: |
6868
| 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: |
6969
| 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: |
70-
| Healthy Places | Road Safety | :x: | :x: | :x: | :x: - data unavailable | :x: |
70+
| 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: |
7171
| Healthy Places | Road Traffic Volume | :x: | :x: | :x: | :x: TO DO | :x: |
7272
| 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:|
7373
| 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: |

0 commit comments

Comments
 (0)