Package: stats19 4.2.0

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 2025. 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], Roger Beecham [aut]

stats19_4.2.0.tar.gz
stats19_4.2.0.zip(r-4.7-any)stats19_4.2.0.zip(r-4.6-any)stats19_4.2.0.zip(r-4.5-any)
stats19_4.2.0.tgz(r-4.6-any)stats19_4.2.0.tgz(r-4.5-any)
stats19_4.2.0.tar.gz(r-4.7-any)stats19_4.2.0.tar.gz(r-4.6-any)
stats19_4.2.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
stats19/json (API)

# Install 'stats19' in R:
install.packages('stats19', repos = c('https://packages.ropensci.org', '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

10.28 score 74 stars 287 scripts 918 downloads 31 exports 41 dependencies

Last updated from:7f0f64d545 (on master). Checks:10 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK178
pkgdown docsOK388
source / vignettesOK372
linux-releaseOK169
macos-releaseOK117
macos-oldrelOK116
windows-develOK164
windows-releaseOK119
windows-oldrelOK106
wasm-releaseOK164

Exports:clean_makeclean_make_modelclean_modeldl_stats19extract_make_stats19find_file_nameformat_casualtiesformat_collisionsformat_column_namesformat_pppformat_sfformat_vehiclesget_data_directoryget_MOTget_parquet_directoryget_stats19get_stats19_adjustmentsget_ULEZget_urljunction_statuslocate_fileslocate_one_filematch_tagread_casualtiesread_collisionsread_vehiclesselect_fileset_data_directoryset_parquet_directorystats19_to_parquetsummarise_adjusted_severities

Dependencies:bitbit64classclassIntclicliprcpp11crayoncurlDBIdplyre1071genericsgluehmsjsonliteKernSmoothlifecyclelubridatemagrittrpillarpkgconfigprettyunitsprogressproxyR6Rcppreadrrlangs2sftibbletidyselecttimechangetzdbunitsutf8vctrsvroomwithrwk

DuckDB and Parquet engines
Introduction | Load the package | Equivalence test with 2024 data | Comparing record counts and fatal counts | Using waldo for deep comparison | Working with large datasets (1979-latest) | Caching the data as Parquet | Where Parquet files live | Converting CSVs to Parquet | Reading from the cache | Keep the cache up to date

Last update: 2026-09-22
Started: 2026-03-18

Longitudinal Schema and Filename Evolution (1979–2025)
Overview | 1. Hosting and File Naming Evolution | Package Handling | 2. Nomenclature: "Accident" to "Collision" | 3. The *_historic Column Split | Longitudinal Harmonization | 4. Severity Adjustments (CRASH System Introduction) | Practical Usage | 5. Emerging Vehicles and Variable Additions | 6. Schema Generation Pipeline

Last update: 2026-09-22
Started: 2026-09-22

Introducing stats19
Introduction | Functions | Download STATS19 data | Read STATS19 data | Crash data | Format STATS19 data | Casualties data | Vehicles data | Creating geographic crash data | Joining tables | Time series analysis | Longitudinal trends and severity adjustments | Further work | References

Last update: 2026-09-22
Started: 2018-11-28

stats19: a package for road safety research
Live Documentation & External Posts | Recent Developments: Modernised Architecture (v4.0.0 - v4.2.0) | 1. Unified Longitudinal Schema | 2. Zero-Warning, High-Precision Parsing | 3. Native DuckDB and Parquet Support | 4. Research Tools: Costs and Vehicle Cleaning | Introduction & Package History | Short history and affiliations | What is STATS19 anyway? | The road crash data in stats19 | Note | How stats19 works | Creating geographic crash data | The big picture: road safety | Conclusion | References

Last update: 2026-09-22
Started: 2019-02-15

Training Resources for Road Safety Analysis with R
Overview | Recommended Resources | 1. Reproducible Road Safety Research with R | 2. Geocomputation with R | 3. General R and Data Science | Getting Started with stats19

Last update: 2026-09-22
Started: 2019-10-04

Make and model data in STATS19
Make and model data

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

Reproducing Reported road casualties in Great Britain: pedestrian factsheet
1. Main findings | 2. Pedestrian traffic and reported casualties | 3. How far do pedestrians travel? | 4. Casualty rates per mile travelled | 5. Sex and age comparisons | 6. Which vehicles are involved in collisions with pedestrians? | 7. Time of day of collisions | 8. What type of road? | 9. Vehicle movement on the road

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

Researching vehicles involved in collisions with STATS19 data
Vehicle level variables in the STATS19 datasets | Relationships between vehicle type and crash severity

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

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
Clean vehicle makeclean_make
Clean vehicle make and modelclean_make_model
Clean vehicle modelclean_model
Download STATS19 data for a yeardl_stats19
Extract vehicle make from generic make/model stringextract_make_stats19
stats19 file names for easy accessfile_names
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
Get Parquet directoryget_parquet_directory
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
Classify collisions as at a junction or notjunction_status
Locate a file on disklocate_files
Pin down a file on disk from parameters.locate_one_file
Match STATS19 collisions with TAG (RAS4001) cost estimatesmatch_tag
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
Interactively select from optionsselect_file
Set data download dirset_data_directory
Set Parquet directoryset_parquet_directory
Stats19 schema and variablesstats19_schema stats19_variables
Convert raw STATS19 CSV files to Parquetstats19_to_parquet
Summarise STATS19 severities with DfT adjustmentssummarise_adjusted_severities
Sample of stats19 data (2022 vehicles)vehicles_sample vehicles_sample_raw