This is an overview of an R package that contains functions to read in, summarize, and map car crash fatality data available from the National Highway Traffic Safety Admnistration's FARS dataset.
library(FARS) library(dplyr) library(maps)
The FARS package is composed of the following elements or data handling routines:
fars_read: This function reads data on car accidents into R and displays it as a table make _file_name: This function sets the file name for the data that was imported in the Fars Read function fars_read_years: This function applies the Make File Name function above to a set of specified years fars_summarize_years:This function summarizes the data by counting up the number of observations by year and month. fars_map_state: This function creates a map showing the location of car accidents in a given state in a given year
The following packages are loaded and required by the package.
library(FARS) library(maps)
Data files can be found at
list.files(system.file("extdata", package = "FARS"))
df<-fars_read("accident_2014.csv.bz2")
df<-make_filename(2013)
df<-fars_read_years(2013:2015)
fars_summarize_years(2013:2015)
fars_map_state(23,2015)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.