knitr::opts_chunk$set( library(testpack), collapse = TRUE, comment = "#>" ) df <- fars.test.df
testpack
is meant for loading and visualizing data from the US National Highway Traffic Safety Administration's Fatality Analysis Reporting System. The following functions are contained:
make_filename
generates a string according to the format of FARS dataset file names, mainly adopted for internal usefars_read
loads a full dataset from file. An appropriate file name must be provided in inputfars_read_years
loads the MONTH
and year
columns of all the accidents occurred in the years provided in inputfars_summarize_years
produces a data frame summarizing the number of accidents per month for each year provided in inputfars_map_state
draws a map with marks representing the geographic locations of the occurrence of the accidents, for the year and the state provided in inputtestpack
at workmake_filename
is internally used to generate appropriate FARS data file names. Appropriate input is expected in order to generate meaningful file names.
make_filename(2013) make_filename("2015") make_filename(3.14159)
fars_read
loads a full dataset from an appropirate FARS file.
df <- fars_read(2018)
The data frame should look like this:
head(df, 7)
fars_read_years
loads the MONTH
and year
columns of all the accidents occurred in the years provided in input
df <- fars_read(2018)
The data frame should look like this:
df1 <- dplyr::select(df, MONTH, YEAR)
head(df1, 9)
fars_summarize_years
produces a data frame summarizing the number of accidents per month for each year provided in input
df <- fars_read_years( c(2013, 2018) )
fars_map_state
draws a map with marks representing the geographic locations of the occurrence of the accidents, for the year and the state provided in input
Check out also the the help of the functions for additional details. The package comes along with a data frame fars.data.df
, obtained randomly sampling 1,000 entries of the FARS data of year 2013.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.