knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(fars) setwd(system.file("exdata", package = "fars"))
This package provides functionality to interact with the \href{Fatality Analysis Reporting System}{https://www.nhtsa.gov/research-data/fatality-analysis-reporting-system-fars} database.
Given a set of .csv.gz
datafiles, summaries about the number of accidents per year
The FARS package needs data files for each year.
The files need to be provided in the working directory and named accident_YEAR.csv.bz2
.
They can be read using the fars_read_years
function, which returns a list of accidents counts by month and year.
setwd(system.file("exdata", package = "fars")) fars_read_years(2013)
You can get a report about years by using the function fars_summarize_years
.
setwd(system.file("exdata", package = "fars")) print(dir(getwd())) fars_summarize_years(c(2013))
Finally, you get a plot of all the accidents in a state using the fars_map_state
function.
setwd(system.file("exdata", package = "fars")) fars_map_state(4, 2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.