fars package reads and map Fatality Analysis Reporting System (FARS) data for states in US
from the National Highway Traffic Safety
Administration.
FARS is using 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.
library(fars) library(maps) library(dplyr)
Datafiles in the package are:
list.files(system.file("extdata", package = "fars"))
fars_readread in a data file as a tibble named "data":
dat<-fars_read("accident_2013.csv.bz2")
make_filenameMake the filename like "accident_2013.csv.bz2", depend on the year.
make_filename(2013)
fars_read_yearsfars_read_years(2013)
fars_summarize_yearsSummarizes yearly accidents data, by month.
plot(fars_summarize_years(2015)) fars_summarize_years(c(2015, 2014))
fars_map_stateThe function displays a state map plot showing the distribution. The state.num is between 1 to 56.
fars_map_state(34,2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.