knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This document will provide you with inforation on the basics functions available in the package fars that uses the FARS (Fatality Analysis Reporting System) and datasets.
The functions provided for you in this package will be 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. You can download the example data here
Running the function "fars_read_years(year(s))" will return either a tibble or a list of tibbles containing some 50 variables or more like the fatalities per state, the state Id, the longitude and latitude of the accident, the number of victims, the weather conditions, etc...
library(fars) datas1 <- 2013 datas2 <- c(2013, 2014, 2015) fars_read_years(datas1) fars_read_years(datas2)
The function "fars_summarize_years(year(s))" will return a summary per month of fatalities if you load only one year. When multiple years are loaded it will return a monthly summary per year.
fars_summarize_years(2013)
The function "fars_map_state(state, year)" will plot the fatalities per state per year on a US state map by using the geolocation of the accidents.
A list of all the state codes can be found with the base "state.name"
fars_map_state(13, 2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.