Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

California Crash Analyzer

An interactive R Shiny dashboard for exploring a decade of California traffic collision data (2014–2023) through linked charts, an interactive severity map, and a filterable data table.

🔗 Live demo: https://andreasjackson.shinyapps.io/California_Crashes/

Runs out of the box. Clone it, install the packages, and go — a 50,000-record sample is bundled. See Data to swap in the full 1.7M-record dataset.


Overview

California's SWITRS collision records are rich but unwieldy: 1.7 million rows and thirty-plus coded columns in a single 400 MB file. This app turns that into something you can actually ask questions of — Which violation categories dominate fatal crashes in a given city? Where do collisions cluster geographically? How has severity shifted year over year?

The dashboard is organized into three tabs, each with its own filter set.

Explore

Five exploratory plots driven by Year, City, and Collision Severity filters — covering collision types, contributing violation categories, temporal patterns, and severity breakdowns.

Map

A Leaflet map plotting individual collisions at their reported coordinates, colored by a severity palette with a legend, over a CartoDB Positron basemap. Filters for Year, Type of Collision, Collision Severity, and Type of Violation isolate specific crash profiles geographically.

Table

A searchable, sortable table of the filtered records — the rows behind whatever you found in the other two tabs.

Tech stack

Purpose Package
App framework shiny
Data wrangling tidyverse, lubridate
Interactive mapping leaflet
Charts ggplot2, plotly

Data

Source: SWITRS (Statewide Integrated Traffic Records System), collected by the California Highway Patrol and distributed through the TIMS portal at UC Berkeley SafeTREC. Public records.

The full 2014–2023 extract is ~400 MB — over GitHub's 100 MB per-file limit — so this repo ships crashes_california_sample.csv instead:

  • 50,000 records, stratified at 5,000 per year so every year filter has data
  • Only records with valid in-state coordinates, so the map renders cleanly
  • Reproducible (fixed seed); ~11 MB
  • Spans all 10 years, 4 severity levels, and 442 cities

The sample is a demo convenience, not a research dataset. It's stratified equally by year rather than proportionally, so year-over-year volume comparisons are not meaningful — use the full dataset for genuine analysis.

Using the full dataset

Download a SWITRS extract covering 2014–2023 with the columns declared in app.R, place it in this directory, and update the constant at the top:

CRASH_DATA = "crashes_california_2014_2023.csv"

Expect a slow first load — the explicit col_types spec keeps 1.7M rows parsing predictably, but it's still 400 MB. Memory headroom matters here; the hosted demo runs on the sample for exactly this reason.

Running locally

R -e "install.packages(c('shiny','tidyverse','lubridate','leaflet','plotly'))"
R -e "shiny::runApp('app.R')"

Notes

Built as a data visualization project exploring interactive dashboard design — specifically how to keep a large dataset responsive under user-driven filtering, and how to make geographic severity patterns legible at a glance.

Author

Andreas Jackson

About

Interactive R Shiny dashboard exploring a decade of California traffic collision data (2014-2023) with linked charts, a Leaflet severity map, and a filterable table.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages