knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(devtools) load_all()
This package contains R functions which provide information from the Fatalities Analysis Reporting System. The data is from the \strong{US National Highway Traffic Safety Administration's} \emph{Fatality Analysis Reporting System} (FARS), which is a nationwide census, providing the American public yearly data, regarding fatal injuries suffered in motor vehicle traffic crashes. For more information, see: (https://www.nhtsa.gov/research-data/fatality-analysis-reporting-system-fars)
You can install FARS from GitHub by
library(devtools) install_github("KvEijden/FARS")
The package includes the data from 2013 to 2015 from the Fatalities Analysis Reporting System. The data can be read in the following way:
fars_data_dir <- system.file("extdata", package = "FARS", mustWork = FALSE) fars_data_files <- list.files(fars_data_dir, full.names = TRUE) fars_data_files library(readr) fars_data <- readr::read_csv(fars_data_files[1]) head(fars_data)
To summarize the the number of fatal injuries use the function fars_summarize_years
.
head(fars_summarize_years(2013), n = 4)
To display a map of fatal injuries by state and year use fars_map_state
.
fars_map_state(state.num = "04", year = 2015)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.