knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
farsdata
package loads data from the US National Highway Traffic Safety Administration's Fatality Analysis Reporting System(FARS).FARS
data is a nationwide census providing the American public yearly data regarding fatal injuries suffered in motor vehicle traffic crashes. https://www.nhtsa.gov/Data/Fatality-Analysis-Reporting-System-(FARS).
library(farsdata) library(dplyr) library(maps)
list.files(system.file("extdata", package = "farsdata"))
make_filename
functionA function with input of year from 2013-2015 and returns a file and a path to the data files in the source package.
year_input<-2013 make_filename(year_input)
fars_read_year
functionA function which takes an input of years and uses make_file
function to create a file, and then reads for each year using a function fars_read
. Result of this function will be used as input to function fars_summarize_years
.
library(dplyr) fars_read_years(2015)
fars_summarize_years
functionTaking organized data by function fars_read_year
, summarizes yearly accidents data by month.
fars_summarize_years(c(2013,2014,2015))
fars_map_state
functionIt displays a map of the inpute state of US for these have accidents by location and yearly.
state.num<-20 year_input<-2013 fars_map_state(state.num,year_input)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.