knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
FARS
package imports and generates summary on fatal accidents based on data from the US National Highway Traffic Safety Administration's Fatality Analysis Reporting System, which is a nationwide census providing the American public yearly data regarding fatal injuries suffered in motor vehicle traffic crashes. The source data were from Fatality Analysis Reporting System (FARS)
library(FARS)
Data files included in the package
list.files(system.file("extdata", package = "FARS"))
make_filename
Argument should be one of 2013, 2014 or 2015
make_filename(2013)
fars_read
This function input csv file as data frame
df_fars <- fars_read("accident_2013.csv.bz2") head(df_fars, 3)
fars_read_years
This function returns MONTH column of each year as a combined list. Input should be 2013, 2014, 2015, otherwise the function will generate an error message
This function uses make_file_name
and fars_read
as ancillary functions.
fars_read_years(2013:2015)
fars_summarize_years
This function returns the number of total fatal accident per month in 2013, 2014, 2015 respectively. It uses fars_read as ancillary functions.
df_sum <- fars_summarize_years(2013:2015) df_sum
fars_map_state
fars_map_state(state.num = 30, year = 2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.