knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Fars Package

The Fars package provides function that can be used to analyse 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.

Packages needed

library(readr)
library(magrittr)
library(fars)
library(maps)

Data

Available data for the use of Fatality Analysis Reporting System.

list.files(system.file("extdata", package = "fars"))

Package functions

fars_read

This function reads a csv file and returns a tibble data frame.

make_filename(2013:2015)

fars_summarize_years

This function plots a table with number of accidents per year and month.

setwd(system.file("extdata", package = "fars"))
years <- c(2013, 2014, 2015)
fars_summarize_years(2013:2015)

fars_map_state

This function plots a graph for definded state with all accident locations.

setwd(system.file("extdata", package = "fars"))
state_num <- 49
year <- 2014
fars_map_state(state_num, year)


jamesbertschy/fars documentation built on Oct. 27, 2019, 4:14 a.m.