TRAVIS <- !identical(tolower(Sys.getenv("TRAVIS")), "true") knitr::opts_chunk$set(purl = TRAVIS)
This package is primarily built for educational purposes. The package enables one to explore fatal traffic accidents from 2013-2015 using data from the National Highway Traffic Safety Administration (NHTSA) Fatality Analysis Reporting System (FARS).
The data in this package come from the National Highway Traffic Safety Administration (NHTSA) Fatality Analysis Reporting System (FARS) data.
filename_2013 <- farsdata::make_filename(2013) farsdata::fars_read(filename_2013)
You can find detail information of the data on NHTSA FARS Manuals & Documentation page.
Loading the data can be done by using the make_filename()
and fars_read()
functions
Use the make_filename
command to find out where data is stored on your machine and/or create a filename to save/load new data.
farsdata::make_filename(2014)
Loading data for a signele year can be done by using the function fars_read_years()
with a single year as input. The only data columns selected are MONTH
and year
. This returns a list of length one, and the first element in the list is the tbl_df
(the tidyverse
data frame) listing the month and year for each fatal accident.
farsdata::fars_read_years(years = 2014)[[1]]
Loading multiple years can be done the function fars_read_years()
.
farsdata::fars_read_years(years = 2013:2014)
The fars_summarize_years()
function produces a summary of the simple counts of fatalities by month and year:
farsdata::fars_summarize_years(2013:2014)
By assigning a state ID and a year to the functionfars_map_state
a map that state's fatalities with a dot at the fatality location is created.
State ID numbers can be found here.
library(mapdata) farsdata::fars_map_state(44, 2014) farsdata::fars_map_state(8, 2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.