knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

This package provides convenient functions to extract, aggregate and visualise the Fatality Analysis Reporting System (FARS) data from the US National Highway Traffic Safety Administration, which is a nationwide census providing the American public yearly data regarding fatal injuries suffered in motor vehicle traffic crashes.

Installation

You can install the package from GitHub using the install_github function from devtools as follows

library(devtools)
install_github("Roger-Li/farsPackage")
library(farsPackage)

Load data from the package

data <- system.file("extdata", "accident_2013.csv.bz2", package = "farsPackage")

Read data into a tibble.

library(dplyr)
library(readr)
df <- fars_read(data)

Summarise data

The fars_summarize_years function reads in a vector of files and returns the # of observation by month and year

library(tidyr)
aggregated <- fars_summarize_years(c(2013, 2014, 2015))

Map plot

fars_map_state function is used to draw observations as points on a map

library(maps)
library(graphics)
fars_map_state(48, 2015)


Roger-Li/farsPackage documentation built on May 25, 2019, 1:28 p.m.