| Title: | Explore Victorian Road Crashes |
|---|---|
| Description: | Provides cleaned Victorian road crash data (casualty crashes, 2012 to 2025), local government area boundaries and resident population, with functions to filter crashes by date, summarise them by any variable and calculate rates per 100,000 residents. Includes a Shiny app for exploring how road trauma has changed across Victoria, when and where crashes happen, and which road users are most affected, state-wide or in selected local areas (LGAs). |
| Authors: | Eduardo Vitale [aut, cre, cph] |
| Maintainer: | Eduardo Vitale <[email protected]> |
| License: | AGPL (>= 3) |
| Version: | 0.2.0 |
| Built: | 2026-11-17 17:11:04 UTC |
| Source: | https://github.com/EduVit/roadcrashVIC |
Adds the population and the number of crashes and casualties per 100,000 residents per year to
summarise_crashes(). Groups that cover several years use the population summed over those years.
crash_rates(data, population, by = "year")crash_rates(data, population, by = "year")
data |
A data frame of crashes, such as vic_crashes, optionally filtered with |
population |
A data frame of population by |
by |
|
The columns of summarise_crashes(), plus:
populationResidents, summed over the years in the group.
crashes_per_100kCrashes per 100,000 residents per year.
fatalities_per_100kPeople killed per 100,000 residents per year.
serious_injuries_per_100kPeople seriously injured per 100,000 residents per year.
other_injuries_per_100kPeople with other injuries per 100,000 residents per year.
ksi_per_100kPeople killed or seriously injured per 100,000 residents per year.
# Victoria, year by year crash_rates(vic_crashes, vic_population, by = "year") # Average annual rate in each LGA over 2021 to 2025 vic_crashes |> filter_crashes(start_date = "2021-01-01", end_date = "2025-12-31") |> crash_rates(vic_population, by = "lga_name")# Victoria, year by year crash_rates(vic_crashes, vic_population, by = "year") # Average annual rate in each LGA over 2021 to 2025 vic_crashes |> filter_crashes(start_date = "2021-01-01", end_date = "2025-12-31") |> crash_rates(vic_population, by = "lga_name")
Keep only the crashes that happened between two dates (both included).
filter_crashes( data, start_date = min(data$accident_date), end_date = max(data$accident_date) )filter_crashes( data, start_date = min(data$accident_date), end_date = max(data$accident_date) )
data |
A data frame of crashes with an |
start_date, end_date
|
First and last day to keep, as dates or |
The rows of data between start_date and end_date, with the same columns.
# Crashes in the 2024-25 financial year fy <- filter_crashes(vic_crashes, start_date = "2024-07-01", end_date = "2025-06-30") nrow(fy) # Only a start date: everything from 2020 onwards nrow(filter_crashes(vic_crashes, start_date = "2020-01-01"))# Crashes in the 2024-25 financial year fy <- filter_crashes(vic_crashes, start_date = "2024-07-01", end_date = "2025-06-30") nrow(fy) # Only a start date: everything from 2020 onwards nrow(filter_crashes(vic_crashes, start_date = "2020-01-01"))
Opens the Shiny app included in the package, in the browser or in the RStudio/Positron viewer.
run_app()run_app()
No return value; called for its side effect of launching the app.
if (interactive()) run_app()if (interactive()) run_app()
Counts crashes and people killed and injured in each group, and the number of casualties per 1,000 crashes. KSI is people killed or seriously injured.
summarise_crashes(data, by)summarise_crashes(data, by)
data |
A data frame of crashes, such as vic_crashes, optionally filtered with |
by |
Character vector of columns to group by, for example |
A tibble with one row per group, sorted by the grouping columns, with columns:
crashesNumber of crashes.
fatalitiesPeople killed.
serious_injuriesPeople seriously injured.
other_injuriesPeople with other injuries.
ksiPeople killed or seriously injured.
fatalities_per_1000_crashesPeople killed per 1,000 crashes.
serious_injuries_per_1000_crashesPeople seriously injured per 1,000 crashes.
other_injuries_per_1000_crashesPeople with other injuries per 1,000 crashes.
ksi_per_1000_crashesPeople killed or seriously injured per 1,000 crashes.
summarise_crashes(vic_crashes, by = "hour") vic_crashes |> filter_crashes(start_date = "2022-01-01", end_date = "2024-12-31") |> summarise_crashes(by = c("day_of_week", "hour"))summarise_crashes(vic_crashes, by = "hour") vic_crashes |> filter_crashes(start_date = "2022-01-01", end_date = "2024-12-31") |> summarise_crashes(by = c("day_of_week", "hour"))
Applies summarise_crashes() to all crashes, and to the crashes involving a pedestrian, a cyclist or a motorcyclist.
summarise_vulnerable(data)summarise_vulnerable(data)
data |
A data frame of crashes, such as vic_crashes, optionally filtered with |
A tibble with four rows (All crashes, Pedestrian, Cyclist, Motorcyclist):
a road_user column, then the columns of summarise_crashes().
summarise_vulnerable(vic_crashes)summarise_vulnerable(vic_crashes)
One row per road crash in Victoria in which at least one person was injured or killed, from 1 January 2012 to 31 December 2025, as recorded by Victoria Police.
vic_crashesvic_crashes
A tibble with 202,065 rows and 51 columns:
(character) Unique crash identifier.
(Date) Date of the crash.
(integer) Year of the crash.
(factor) Month of the crash, Jan to Dec.
(factor) Day of the week, Monday to Sunday.
(integer) Hour of the day, 0 to 23 (17 means 5:00pm to 5:59pm).
(character) Type of crash, for example Collision with vehicle or Struck Pedestrian.
(character) Detailed crash type (Definitions for Classifying Accidents).
(character) Light at the time of the crash, for example Day or Dark No street lights.
(character) Whether police attended the scene (Yes or No).
(character) Road layout, for example T intersection or Not at intersection.
(factor) Severity of the crash: Fatal accident, Serious injury accident or Other injury accident.
(ordered factor) Speed limit, 30 km/h to 110 km/h, then Off road and Other.
(character) Whether the vehicle ran off the road (Yes or No).
(character) Road name and type, for example Alfred Street.
(character) Local government area (LGA), spelled as in vic_lga.
(character) Department of Transport and Planning region.
(numeric) Latitude of the crash.
(numeric) Longitude of the crash.
(numeric) People involved.
(numeric) People killed or injured.
(numeric) People killed.
(numeric) People seriously injured.
(numeric) People with other injuries.
(numeric) People not injured.
(numeric) Males involved.
(numeric) Females involved.
(numeric) Cyclists involved.
(numeric) Passengers involved.
(numeric) Drivers involved.
(numeric) Pedestrians involved.
(numeric) Pillion passengers involved.
(numeric) Motorcyclists involved.
(numeric) Road users of unknown type involved.
(numeric) Pedestrians and cyclists aged 5 to 12 involved.
(numeric) Pedestrians and cyclists aged 13 to 18 involved.
(numeric) Pedestrians aged 65 and over involved.
(numeric) Drivers aged 75 and over involved.
(numeric) Drivers aged 18 to 25 involved.
(numeric) Vehicles involved, including bicycles.
(numeric) Heavy vehicles involved.
(numeric) Passenger vehicles involved.
(numeric) Motorcycles involved.
(numeric) Public transport vehicles involved (tram, bus or train).
(character) How urban the location is, for example MELB_URBAN or RURAL_VICTORIA.
(character) Road classification, for example Freeway or Local Road.
(character) Whether the road is divided (Divided or Undivided).
(character) Statistical division (Metro or Country).
(logical) At least one pedestrian involved.
(logical) At least one cyclist involved.
(logical) At least one motorcyclist or pillion passenger involved.
Victorian Government (Department of Transport and Planning), Victorian road crash data, https://discover.data.vic.gov.au/dataset/victoria-road-crash-data, licensed under CC BY 4.0. Data last updated 13 October 2026; retrieved 25 October 2026.
Changes made: kept casualty crashes up to 31 December 2025; cleaned column names; added year, month,
hour, road_full_name and the involves_* columns; converted categories to factors; set Unk., Unknown and Not known to NA; matched LGA
names to vic_lga; removed ACCIDENT_TIME, VICGRID_X, VICGRID_Y, ROAD_ROUTE_1, ROAD_NAME, ROAD_TYPE,
DCA_CODE and SRNS.
Simplified boundaries of the local government areas (LGAs) in Victoria, for mapping.
vic_lgavic_lga
An sf object (a tibble with a geometry column) with 80 rows and 4 columns:
(character) ABS LGA code.
(character) LGA name in capitals, for example MERRI-BEK.
(logical) TRUE for the unincorporated areas (alpine resorts and islands).
(sfc_MULTIPOLYGON) Boundary, in longitude and latitude (WGS 84).
Department of Transport and Planning, State of Victoria, Vicmap Admin - Local Government Area (LGA) Polygon Aligned to Property (resource LGA_POLYGON, metadata ID cff349f9-3ef3-51bd-b5a9-ae650f6d6c24), published 16 October 2026, licensed under CC BY 4.0. Retrieved 25 October 2026. https://discover.data.vic.gov.au/dataset/vicmap-admin-local-government-area-lga-polygon-aligned-to-property.
Changes made: kept the ABS code and name; merged the unincorporated areas into one UNINCORPORATED VIC
feature; added unincorporated; converted to WGS 84; simplified with a 100 m tolerance; sorted by name.
Estimated resident population of each Victorian local government area (LGA) at 30 June, 2012 to 2025.
vic_populationvic_population
A tibble with 1,120 rows and 4 columns:
(character) ABS LGA code.
(character) LGA name in capitals, spelled as in vic_lga and vic_crashes.
(integer) Year (population at 30 June).
(numeric) Estimated resident population.
Australian Bureau of Statistics, Regional population, 2024-25 (Cat. no. 3218.0), dataset ERP_LGA2025, https://www.abs.gov.au/statistics/people/population/regional-population/2024-25, licensed under CC BY 4.0. Retrieved 25 October 2026. Changes made: kept Victorian LGAs for 2012 to 2025; renamed columns; LGA names in capitals without the "(Vic.)" suffix.