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

Package Description

FARS package imports and generates summary on fatal accidents based on 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 source data were from Fatality Analysis Reporting System (FARS)

Load Packages

library(FARS)

Load Data

Data files included in the package

list.files(system.file("extdata", package = "FARS"))

Package Functions

Function make_filename

Argument should be one of 2013, 2014 or 2015

make_filename(2013)

Function fars_read

This function input csv file as data frame

df_fars <- fars_read("accident_2013.csv.bz2")

head(df_fars, 3)

Function fars_read_years

This function returns MONTH column of each year as a combined list. Input should be 2013, 2014, 2015, otherwise the function will generate an error message This function uses make_file_name and fars_read as ancillary functions.

fars_read_years(2013:2015)

Function fars_summarize_years

This function returns the number of total fatal accident per month in 2013, 2014, 2015 respectively. It uses fars_read as ancillary functions.

df_sum <- fars_summarize_years(2013:2015)

df_sum

Function fars_map_state

fars_map_state(state.num = 30, year = 2013)


ChaoLiu-gk/FARS documentation built on Jan. 6, 2020, 12:43 a.m.