knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The make_filename() function creates the filename of a dataset based on the year you input. The output from this function can be used by the fars_read() function.
Note: There is no error checking here, so it is possible to put in a year that will not end up reading in a dataset.
|Parameters |Description |
|---------------|----------------------------------------------------------------|
|year| A numeric input used to define a filename you want to read in.|
make_filename(2015)
The fars_read() function reads in data from the Fatality Analysis Reporting System (FARS). The input is a filename. If the filename cannot be found then an error will be returned, otherwise the file will be read in.
|Parameters |Description | |---------------|--------------------------------------------------| |filename| A string input containing the filename you want read in.|
fars_read("accident_2015.csv.bz2")
The fars_read_years() function reads in multiple years of data and summarizes accidents by month and year. This function will return a list for each year of data read in. Invalid year inputs will generate a warning message, but as long as there is at least one valid year then this function will return a list.
|Parameters |Description | |---------------|-----------------------------------------------------------------| |years| A list of numeric values for the years you want to summarize FARS data for|
fars_read_years(c(2014,2015))
The fars_summarize_years() function will summarize the specified data by month and year in a table. Invalid year inputs will generate a warning message, but as long as there is at least one valid year input then this function will return a table.
|Parameters |Description | |---------------|-----------------------------------------------------------------| |years| A list of numeric values for the years you want to summarize FARS data for|
fars_summarize_years(c(2014,2015))
The fars_map_state() function will output a graphical map showing where within a state fatal accidents occur. State numbers outside of the valid range (1-56) will generate an error. States with no accidents to plot will generate a warning message. This function will also generate errors for invalid year inputs.
|Parameters |Description | |---------------|-----------------------------------------------------------------| |state.num| A numeric value that represents the state you want to plot data for | |years| A list of numeric values for the years you want to summarize FARS data for |
fars_map_state(45, 2015)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.