Work with Open Road Traffic Casualty Data from Great Britain
Local helper to be reused.
Download STATS19 data for a year
Find file names within stats19::file_names.
Format STATS19 casualties
Format STATS19 'collisions' data
Format column names of raw STATS19 data
Convert STATS19 data into ppp (spatstat) format.
Format convert STATS19 data into spatial (sf) object
Format STATS19 vehicles data
Get data download dir
Download vehicle data from the DVSA MOT API using VRM.
Download and read-in severity adjustment factors
Download, read and format STATS19 data in one function.
Download DVLA-based vehicle data from the TfL API using VRM.
Convert file names to urls
Locate a file on disk
Pin down a file on disk from four parameters.
Generate a phrase for data download purposes
Read in STATS19 road safety data from .csv files downloaded.
Read in STATS19 road safety data from .csv files downloaded.
Read in stats19 road safety data from .csv files downloaded.
Interactively select from options
Set data download dir
Work with and download road traffic casualty data from Great Britain. Enables access to the UK's official road safety statistics, 'STATS19'. Enables users to specify a download directory for the data, which can be set permanently by adding `STATS19_DOWNLOAD_DIRECTORY=/path/to/a/dir` to your `.Renviron` file, which can be opened with `usethis::edit_r_environ()`. The data is provided as a series of `.csv` files. This package downloads, reads-in and formats the data, making it suitable for analysis. See the stats19 vignette for details. Data available from 1979 to 2024. See the official data series at <https://www.data.gov.uk/dataset/cb7ae6f0-4be6-4935-9277-47e5ce24a11f/road-accidents-safety-data>. The package is described in a paper in the Journal of Open Source Software (Lovelace et al. 2019) <doi:10.21105/joss.01181>. See Gilardi et al. (2022) <doi:10.1111/rssa.12823>, Vidal-Tortosa et al. (2021) <doi:10.1016/j.jth.2021.101291>, Tait et al. (2023) <doi:10.1016/j.aap.2022.106895>, and León et al. (2025) <doi:10.18637/jss.v114.i09> for examples of how the data can be used for methodological and empirical research.
Useful links