library(fars) library(dplyr) library(maps)
This vignette descripbes the functions and use cases of the FARS package. The package contains a number of functions for analysis of the yearly records from US National Highway Traffic Safety Administration's Fatality Analysis Reporting System. FARS data is the public data regarding fatal injuries suffered in motor vehicle traffic crashes.
Here is a list functions included in the package:
This function creates a filename as accident_
filename <- make_filename(2014) print(filename)
This function reads CSV file defined by "filepath" for earlier created filename r filename
and returns a tibble (data.frame).
filepath <- system.file("data", filename, package = "fars") accident_2014 <- fars_read(filepath) print(head(accident_2014))
This function accepts a vector or list of years "years", where the records from US National Highway Traffic Safety Administration's Fatality Analysis Reporting System should be available. It returns a list of the data.frames with two columns (MONTH, year).
accidents <- fars_read_years(2013) print(accidents)
This function accepts a vector or list of years "years", where the records from US National Highway Traffic Safety Administration's Fatality Analysis Reporting System should be available. It calculates a number of accidents per month and year and returns a tibble (data.frame) with months in rows and years in columns.
summary <- fars_summarize_years(2013:2015) print(summary)
This function creates a plot with all incidents in specific US state (defined by "state.num") per indicaed "year". The "year" should correspond to the recorded analysis from US National Highway Traffic Safety Administration's Fatality Analysis Reporting System.
fars_map_state(1, 2013)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.