library(magrittr)
library(dplyr)
library(tidyr)
library(maps)
library(graphics)
source("../R/fars_functions.R")

This package is designed to analyse and plot data from the Fatality Analysis Reporting System, or FARS. Information about the FARS system is available at this address.

FARS Data

This package is designed to parse FARS data stored by year in comma separated values format. The data should be saved in the working directory.

Dependencies

This package requires several packages to be available in order to funcion: magrittr dplyr tidyr maps * graphics

Using the Package

Two functions in the package will be of interest to users: "fars_summarize_years(years)"" and "fars_map_state(state.num, year)". Other functions, "fars_read"", "make_filename"" and "fars_read_years" are made available for the purposes of error checking, but will be of little interest in terms of data analysis.

Analysing FARS Incident Counts

The "fars_summarize_years(years)"" function produces a summary table of the number of FARS incidents in each month of a given year or group of years. For example, if data were available for 2013, 2014 and 2015, a summary table of incidents by month in each of those years could be generated by:

fars_summarize_years(c(2013, 2014, 2015))

Mapping FARS Incidents in a State

The "fars_map_state(state.num, year)"" produces a map of all FARS incidents in a state in a given year. For example, to plot all of the FARS incidents in California in 2014, use the following code:

fars_map_state(6,2014)

Which should produce the plot below:

fars_map_state(6,2014)

A vector map of California, with dots indicating the locatoin of each FARS incident.



expo45/wk4project documentation built on May 16, 2019, 9:56 a.m.