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:

testpack at work

make_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

Additional info

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.



fmax85/testpack documentation built on May 12, 2019, 7:18 p.m.