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

FARS datasets

The package contains data from the US National Highway Traffic Safety Administration's Fatality Analysis Reporting System, which is a nationwide census providing the American public yearly data regarding fatal injuries suffered in motor vehicle traffic crashes. The package allows easy reporting of FARS data sets from 2013, 2014 and 2015.

FARS reporting

The farsReport package provides two functions for FARS reporting, the first is returning a tibble summarising the FARS for specified set of years, the second is plotting the FARS accidents on the map of the specified state, for specified year.

FARS summary

The fars_summarize_years(years) function will summarize the FARS accidents per month and year, for given set of years.

library(farsReport)
farsReport::fars_summarize_years(years = c(2013, 2014))

FARS mapplot per state

The fars_map_state(state.num, year) function will plot FARS accidents for specififed year on border map of the state (specified by state.num parameter). This function does not return any data, the side effect of the function is the plot of FARS accident on the border map of the state.

library(farsReport)
farsReport::fars_map_state(state.num = 13, year = 2014)
farsReport::fars_map_state(state.num = 34, year = 2014)

FARS data structure

The function responsible for reading the data is fars_read(filename), whereas filename argument is generated via the fars_make_filename(year) function, which returns path to a year dataset from saved range of years 2013-2015 (with default year being 2013).

The structure of an example dataset (for year 2013) is written below:

library(farsReport)
knitr::kable(str(farsReport::fars_read(farsReport::fars_make_filename())))


xzguqgsntdzq/Review_2 documentation built on May 13, 2019, 4:48 p.m.