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.
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.
This package requires several packages to be available in order to funcion: magrittr dplyr tidyr maps * graphics
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.
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))
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.