library(fars) library(dplyr) library(maps)
This vignette provides an introduction to the fars package of functions for the analysis of data from the Fatality Analysis Reporting System (FARS).
To install the fars package from GitHub:
install.packages("devtools") devtools::install_github("axelbudde/fars")
The fars package offers three functions:
fars_read()
fars_summarize_years()
fars_map_state()
Examples are provided for each function, using FARS data from the years 2013 to 2015. The corresponding data files can be found in the \extdata
folder.
With fars_read()
a file path can be defined. The function read the corresponding data file and returns a tibble.
filename <- system.file("extdata/accident_2014.csv.bz2", package = "fars") fars_read(filename)
With fars_summarize_years()
summarizes the number of accidents by year and month by means of a pivot table. The function accepts a year or a range of years as arguments (integer).
setwd(system.file("extdata", package = "fars")) fars_summarize_years(2013:2015)
The function fars_map_state()
plots accident locations in a certain state and year, using state index and year as arguments.
setwd(system.file("extdata", package = "fars")) fars_map_state(33, 2015)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.