library(fars)
library(dplyr)
library(maps)

Introduction

This vignette descripbes the functions and use cases of the FARS package. The package contains a number of functions for analysis of the yearly records from US National Highway Traffic Safety Administration's Fatality Analysis Reporting System. FARS data is the public data regarding fatal injuries suffered in motor vehicle traffic crashes.

Functions

Here is a list functions included in the package:

make_filename()

This function creates a filename as accident_.csv.bz2, where is substituted by the function input "year".

filename <- make_filename(2014)
print(filename)

fars_read()

This function reads CSV file defined by "filepath" for earlier created filename r filename and returns a tibble (data.frame).

filepath <- system.file("data", filename, package = "fars")
accident_2014 <- fars_read(filepath)
print(head(accident_2014))

fars_read_years()

This function accepts a vector or list of years "years", where the records from US National Highway Traffic Safety Administration's Fatality Analysis Reporting System should be available. It returns a list of the data.frames with two columns (MONTH, year).

accidents <- fars_read_years(2013)
print(accidents)

fars_summarize_years()

This function accepts a vector or list of years "years", where the records from US National Highway Traffic Safety Administration's Fatality Analysis Reporting System should be available. It calculates a number of accidents per month and year and returns a tibble (data.frame) with months in rows and years in columns.

summary <- fars_summarize_years(2013:2015)
print(summary)

fars_map_state()

This function creates a plot with all incidents in specific US state (defined by "state.num") per indicaed "year". The "year" should correspond to the recorded analysis from US National Highway Traffic Safety Administration's Fatality Analysis Reporting System.

fars_map_state(1, 2013)


androsova/fars documentation built on May 10, 2019, 11:44 a.m.