knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This package allows you to determine the number of accidents per month in the United States National Highway Traffic Safety Administration's Fatality Analysis Reporting System (FARS) data and map these accidents within each state.
The latest development version of the package can be found on GitHub and can be directly loaded using the following code:
library(devtools) install_github("mahonmb/FARSfun") library(FARSfun)
The data used in these examples can be found at the United States National Highway Traffic Safety Administration's Fatality Analysis Reporting System
As a very simple example, here is how you can determine the number of accidents per month in a given year:
fars_summarize_years(2013)
The column of MONTH
is an integer giving the number of each month in order from 1 to 12. The column of '2013'
is an integer that represents that number of fatal accidents within each month of 2013. Note that '2013'
will change depending on the year reported.
Additionally, you are able to map the location of fatal accidents within each state (using state.num
to indicate the state - numbers correspond to alphabetical ordering of the states) for a given year (using year
).
#Here I map fatal accidents in Alabama in 2013 fars_map_state(1,2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.