Package: stats19 3.4.0.9000

Robin Lovelace

stats19: Work with Open Road Traffic Casualty Data from Great Britain

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.

Authors:Robin Lovelace [aut, cre], Malcolm Morgan [aut], Layik Hama [aut], Mark Padgham [aut], David Ranzolin [rev], Adam Sparks [rev, ctb], Ivo Wengraf [ctb], RAC Foundation [fnd], Blaise Kelly [aut]

stats19_3.4.0.9000.tar.gz
stats19_3.4.0.9000.zip(r-4.6)stats19_3.4.0.9000.zip(r-4.5)stats19_3.4.0.9000.zip(r-4.4)
stats19_3.4.0.9000.tgz(r-4.5-any)stats19_3.4.0.9000.tgz(r-4.4-any)
stats19_3.4.0.9000.tar.gz(r-4.6-any)stats19_3.4.0.9000.tar.gz(r-4.5-any)
stats19_3.4.0.9000.tgz(r-4.5-emscripten)
stats19.pdf |stats19.html
stats19/json (API)
NEWS

# Install 'stats19' in R:
install.packages('stats19', repos = c('https://ropensci.r-universe.dev', 'https://cloud.r-project.org'))

Reviews:rOpenSci Software Review #266

Bug tracker:https://github.com/ropensci/stats19/issues

Pkgdown/docs site:https://docs.ropensci.org

Datasets:

On CRAN:

Conda:

stats19road-safetytransportcar-crashesropenscidata

9.72 score 66 stars 211 scripts 1.7k downloads 17 exports 42 dependencies

Last updated from:2fb9f0fc63 (on master). Checks:10 OK. Indexed: yes.

TargetResultTotal timeArtifact
linux-devel-x86_64OK177
pkgdown docsOK335
source / vignettesOK385
linux-release-x86_64OK174
macos-release-arm64OK102
macos-oldrel-arm64OK167
windows-develOK116
windows-releaseOK96
windows-oldrelOK98
wasm-releaseOK157

Exports:dl_stats19find_file_nameformat_casualtiesformat_collisionsformat_column_namesformat_pppformat_sfformat_vehiclesget_data_directoryget_MOTget_stats19get_stats19_adjustmentsget_ULEZlocate_one_fileread_casualtiesread_collisionsread_vehicles

Dependencies:bitbit64classclassIntclicliprcpp11crayoncurlDBIdplyre1071genericsgluehmsjsonliteKernSmoothlifecyclelubridatemagrittrMASSpillarpkgconfigprettyunitsprogressproxyR6Rcppreadrrlangs2sftibbletidyselecttimechangetzdbunitsutf8vctrsvroomwithrwk

An introduction to road safety analysis with R: setup notes

Rendered fromstats19-training-setup.Rmdusingknitr::rmarkdownon Oct 17 2025.

Last update: 2025-01-13
Started: 2019-10-03

Introduction to R for road safety: an introduction to R and practical exercises

Rendered fromstats19-training.Rmdusingknitr::rmarkdownon Oct 17 2025.

Last update: 2023-10-11
Started: 2019-10-04

Make and model data in STATS19

Rendered frommake.Rmdusingknitr::rmarkdownon Oct 17 2025.

Last update: 2025-10-17
Started: 2025-10-17

Reproducing Reported road casualties in Great Britain: pedestrian factsheet

Rendered fromfactsheet.Rmdusingknitr::rmarkdownon Oct 17 2025.

Last update: 2025-10-08
Started: 2025-10-08

Researching vehicles involved in collisions with STATS19 data

Rendered fromstats19-vehicles.Rmdusingknitr::rmarkdownon Oct 17 2025.

Last update: 2024-10-28
Started: 2019-08-20

Introducing stats19

Rendered fromstats19.Rmdusingknitr::rmarkdownon Oct 17 2025.

Last update: 2025-10-08
Started: 2018-11-28

stats19: a package for road safety research

Rendered fromblog.Rmdusingknitr::rmarkdownon Oct 17 2025.

Last update: 2025-10-16
Started: 2019-02-15

Readme and manuals

Help Manual

Help pageTopics
Sample of stats19 data (2022 collisions)accidents_sample accidents_sample_raw
Sample of stats19 data (2022 casualties)casualties_sample casualties_sample_raw
Local helper to be reused.check_input_file
Download STATS19 data for a yeardl_stats19
stats19 file names for easy accessfile_names file_names_old
Find file names within stats19::file_names.find_file_name
Format STATS19 casualtiesformat_casualties
Format STATS19 'collisions' dataformat_collisions
Format column names of raw STATS19 dataformat_column_names
Convert STATS19 data into ppp (spatstat) format.format_ppp
Format convert STATS19 data into spatial (sf) objectformat_sf
Format STATS19 vehicles dataformat_vehicles
Get data download dirget_data_directory
Download vehicle data from the DVSA MOT API using VRM.get_MOT
Download, read and format STATS19 data in one function.get_stats19
Download and read-in severity adjustment factorsget_stats19_adjustments
Download DVLA-based vehicle data from the TfL API using VRM.get_ULEZ
Convert file names to urlsget_url
Locate a file on disklocate_files
Pin down a file on disk from four parameters.locate_one_file
Generate a phrase for data download purposesphrase
Police force boundaries in England (2016)police_boundaries
Read in STATS19 road safety data from .csv files downloaded.read_casualties
Read in STATS19 road safety data from .csv files downloaded.read_collisions
Read in stats19 road safety data from .csv files downloaded.read_vehicles
Schema for stats19 data (UKDS)schema_original
Interactively select from optionsselect_file
Set data download dirset_data_directory
Stats19 schema and variablesstats19_schema stats19_variables
Sample of stats19 data (2022 vehicles)vehicles_sample vehicles_sample_raw