knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library('FARScoursera')
library('dplyr')
library('tidyr')
library('readr')
library('maps')

This package allows users to load, summarize, and visualize data on fatal motor vehicle accidents from the National Highway Traffic Safety Administration's Fatality Analysis Reporting System, which is a nationwide census tracking annual fatal injuries.

The package includes five functions to read the data, create a file, read the years, summarize the data by year, and to create the visualization at the state level.

Reading the data

The first option to loade data is with the fars_read() function. This creates a tibble.

df=fars_read()

Making the file name

This creates a standard file name for the data. This take the year as the only argument.

make_filename(2013)

Reading the years

This function will create a vector with a list of monthly data for the given years. This also utilizes the make_filename function and so creates files for each year automatically.

fars_read_years(c(2013:2015))

Summarizing by Year

This creates a summary of all accidents by month for the selected years.

fars_summarize_years(c(2013:2015))

Creating the visualization

This plots the frequency of accidents in the selected state(s) for a selected year. Users can select multiple states but only a single year. The maps are drawn using the map() function from the "maps" package. The function takes two arguments. First is the state number, a numeric code for each state. The full list of codes can be found in the function's documentation. The second argument is the year.

fars_map_state(state.num, year)


mcuddy76/FARScoursera documentation built on May 9, 2019, 10:42 a.m.