The following functions read, summarize and plot data from the US National Highway Traffic Safety Administration's Fatality Analysis Reporting System (FARS)
The FARSpckgwk4
package includes the following functions:
This function returns a data frame table when the file exists. An error is given if the file doesn't exist. The file has to be located in the present working directory
my_data <- fars_read("accident_2013.csv.bz2")
This function creates the FARS file name based in the year covered by the data
my_file <- make_filename(2013) my_file <- make_filename("2013")
This function extracts months and years of every FARS file within the years specified. An error is retuned for invalid years specified when the FARS file doesn't exits for that year
my_data <- fars_read_years(c(2013, 2014, 2015)) my_data <- fars_read_years(c("2013", "2014", "2015"))
This functions gives a summary of the fatalities by month for every FARS files read by year
fars_summarize_years(c(2013, 2014)) fars_summarize_years(c("2013", "2014"))
This function generates a US state map with the locations of the fatalities for a given year. An error is given if the state number is not present in the data set. If no fatalities present a messages is generated
fars_map_state(10, 2015) fars_map_state(36, 2014) fars_map_state(50, 2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.