library(FarsPackage)
knitr::opts_chunk$set(echo = TRUE, cache = FALSE)
#knitr::opts_knit$set(root.dir = "C:/Users/User/Documents/R/packages/FarsPackage")

Introduction

This package analyses 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.

Accident data is included from the years 2013, 2014 and 2015. Fatal accident occurences can be summarized by year and month.

Helper Functions

The fars_read, make_filenane and fars_read_years functions serve as helper functions to read the csv files which contain the source data.

The fars_read function takes a filename as its argument.

fars_read(system.file("extdata", "accident_2015.csv.bz2", package = "FarsPackage"))

The filename is created simply with the make_filename function which takes a year as its argument.

make_filename(2013)

A list of files can be read in with the fars_read_years function.

fars_read_years(c(2013,2014,2015)) 

Summary Data

Fatal accident occurences can then be summarized by year and month.

fars_summarize_years(c(2013,2014,2015))

Accident locations in a given year and state can also be plotted on a state map using the maps and graphics packages.

fars_map_state(4, 2015)


johnmwaugh/FarsPackage documentation built on May 24, 2019, 4:06 a.m.