Access data from Australian Road Deaths Database
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
README_cache/markdown_github-ascii_identifiers
docs
man
tests
vignettes
.Rbuildignore
.gitignore
.travis.yml
DESCRIPTION
LICENSE
NAMESPACE
NEWS.md
README-crash plot by year and state-1.png
README-crash plot by year-1.png
README-fatalities plot by age-1.png
README-fatalities plot by year-1.png
README.Rmd
README.md
appveyor.yml
ozroaddeaths.Rproj

README.md

ozroaddeaths Travis-CI Build Status AppVeyor Build Status

ozroaddeaths is a package that pulls data from the Australian Road Deaths Database, run by the Bureau of Infrastructure, Transport and Regional Economics (BITRE). This provides basic details of road transport crash fatalities in Australia as reported by the police each month to the State and Territory road safety authorities. The details provided in the database fall into two groups:

  1. The circumstances of the crash, for example, date, location, crash type

  2. Some details regarding the persons killed, for example, age, gender and road user group.

Installation

You can install ozroaddeaths from github with:

# install.packages("devtools")
devtools::install_github("ropenscilabs/ozroaddeaths")

This data is taken from the Australian Road Deaths Database, which provides basic details of road transport crash fatalities in Australia as reported by the police each month to the State and Territory road safety authorities, obtained from: https://bitre.gov.au/statistics/safety/fatal_road_crash_database.aspx

Details provided in the database fall into two groups:

  • the circumstances of the crash, for example, date, location, crash type

  • some details regarding the persons killed, for example, age, gender and road user group.

The fatality data is updated every month. The heavy vehicle flags (for articulated truck, heavy rigid truck and bus involvement) are only updated each quarter, and are current to within two months. Information for heavy rigid truck involvement in crashes earlier than 2004 is incomplete.

Package Author's Notes

Data was available at URL as at 17/10/26. Data is imported into R and cleaned by removing redundant date columns and transforming into a tidy format.

Indemnity Statement:

The Bureau of Infrastructure, Transport and Regional Economics has taken due care in preparing this information. However, noting that data have been provided by third parties, the Commonwealth gives no warranty as to the accuracy, reliability, fitness for purpose, or otherwise of the information.

Copyright

© Commonwealth of Australia, 2017

This work is copyright and the data contained in this publication should not be reproduced or used in any form without acknowledgement.

Import data from the BITRE website into R

library(ozroaddeaths)
library(dplyr)
library(ggplot2)
library(lubridate)
library(ggridges)
crashes <- oz_road_fatal_crash()
fatalities <- oz_road_fatalities()

Variables available

Crashes

knitr::kable(dplyr::as_data_frame(names(crashes)))
value
crash_id
state
date
month
year
weekday
time
crash_type
n_fatalities
bus
heavy_rigid_truck
articulated_truck
speed_limit
date_time
knitr::kable(head(crashes))
crash_id state date month year weekday time crash_type n_fatalities bus heavy_rigid_truck articulated_truck speed_limit date_time
3.201701e+12 QLD 2017-01-01 1 2017 Sunday 00:00:00 Pedestrian 1 No No No 50 2016-12-31 13:00:00
5.201701e+12 WA 2017-01-01 1 2017 Sunday 16:30:00 Multiple vehicle 1 No No No 100 2016-12-31 13:00:00
5.201701e+12 WA 2017-01-01 1 2017 Sunday 17:14:00 Multiple vehicle 1 No No No 70 2016-12-31 13:00:00
1.201701e+12 NSW 2017-01-02 1 2017 Monday 18:10:00 Single vehicle 1 No No No 50 2017-01-01 13:00:00
1.201701e+12 NSW 2017-01-02 1 2017 Monday 13:15:00 Multiple vehicle 1 No No No 80 2017-01-01 13:00:00
3.201701e+12 QLD 2017-01-02 1 2017 Monday 03:00:00 Pedestrian 1 No No No 100 2017-01-01 13:00:00

Fatalities

knitr::kable(dplyr::as_data_frame(names(fatalities)))
value
crash_id
date_time
month
weekday
time
state
crash_type
bus
heavy_rigid_truck
articulated_truck
speed_limit
road_user
gender
age
knitr::kable(head(fatalities))
crash_id date_time month weekday time state crash_type bus heavy_rigid_truck articulated_truck speed_limit road_user gender age
3.201701e+12 2017-01-01 00:00:00 January Sunday 00:00 QLD Pedestrian No No No 50 Pedestrian Female 64
5.201701e+12 2017-01-01 16:30:00 January Sunday 16:30 WA Multiple No No No 100 Motorcycle rider Male 21
5.201701e+12 2017-01-01 17:14:00 January Sunday 17:14 WA Multiple No No No 70 Driver Male 25
3.201701e+12 2017-01-02 03:00:00 January Monday 03:00 QLD Pedestrian No No No 100 Pedestrian Female 30
1.201701e+12 2017-01-02 13:15:00 January Monday 13:15 NSW Multiple No No No 80 Motorcycle rider Male 26
1.201701e+12 2017-01-02 18:10:00 January Monday 18:10 NSW Single No No No 50 Driver Male 28

Plot crashes by year

crash_plot <- ggplot(crashes,
                     aes(x = year,
                         fill = year)) +
  geom_line(stat = "count") +
  theme_minimal() +
  ggtitle("Annual number of fatal car accidents per year")

crash_plot

Plot crashes by year and state

crash_plot +
  scale_y_continuous(trans = "log2") +
  facet_wrap(~state) +
   ggtitle("Annual number of fatal car accidents per year and state",
           subtitle = "log2 scale" )

Fatalities by year

fatality_plot <- fatalities %>%
  mutate(year = lubridate::year(date_time)) %>%
  ggplot(aes(x =  year, 
             fill = year)) +
  geom_line(stat = "count") +
  theme_minimal() +
  ggtitle("Annual number of road fatalities")

fatality_plot
#> Warning: Removed 40 rows containing non-finite values (stat_count).

fatality_plot <- fatalities %>%
  filter(gender != "Unknown") %>%
  mutate(year = lubridate::year(date_time)) %>%
  ggplot(aes(x = age, 
             fill = gender )) +
  geom_density() +
  facet_wrap(~gender) +
  theme_minimal() +
  ggtitle("Distribution of road fatalities by age 1989 to 2017")

fatality_plot
#> Warning: Removed 78 rows containing non-finite values (stat_density).