library(dplyr) library(readr) library(tidyr) library(maps) library(graphics) library(magrittr)
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.
This vignette goes through the following exported functions in the package:
Make a file name: This function takes year character string and makes a file name that contains the FARS data for that particular year
Input param: year A numeric year in YYYY format
Returns: A character string of the FARS data filename for that year
Examples:
RPackageAssignment::make_filename(2013) RPackageAssignment::make_filename(2014) RPackageAssignment::make_filename(2015)
Read a data file: This function reads a data file containing FARS data
Input param: filename A character string giving the file name for the data
Return: a dataframe with the data in the file
Examples:
data2013 <- RPackageAssignment::fars_read("accident_2013.csv.bz2") ## Number of records in 2013 nrow(data2013)
Read data for a list of years: This function takes a list of years in YYYY format and reads the FARS data for each year
Input param: years A list of years in YYYY format
Returns:
Examples:
data_2013_2015 <- RPackageAssignment::fars_read_years(2013:2015) ## Number of data files between 2013 and 2015 length(data_2013_2015) ## number of records in data for 2013 nrow(data_2013_2015[[1]])
Summarize the data for each year: This function takes a list of years and returns a table of the total number of fatalities per month for each year
Input param: years A list of years in YYYY format
Returns: A table of the total fatalities per month in each year
Examples:
RPackageAssignment::fars_summarize_years(2013:2015)
Map the data for a given state for a given year: This function takes a state number and a given year in YYYY format and displays a geogrphical map of fatalities accross the state for that year.
Input params:
Returns: A geographic map of the state with points representing fatalities during that year
Examples:
## Display data for Maryland in 2014 RPackageAssignment::fars_map_state(24, 2014) ## Display data for Virginia in 2015 RPackageAssignment::fars_map_state(51, 2015)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.