library(minifars)

General Info

This package queries and plot information about fatal traffic accidents using FARS data. FARS represents 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 in motor vehicle traffic crashes. You can find detailed information at the location FARS.

The Data

The package comes with the files accident_2013.csv.bz2, accident_2014.csv.bz2 and accident_2015.csv.bz2. If you want to use the data, use those steps:

  1. the working directory becomes the directory with data
library(minifars)
save_ <- getwd()
dir_data <- system.file("extdata", file="accident_2013.csv.bz2", package="minifars")
setwd(dirname(dir_data))
  1. use the functions from package

  2. return to the original directory

getwd(save_)

Note. It's sufficient to create a directory on your disk (named datafars for example) and copy there the file of data. Before you use the functions from package, set the working directory there.

The functions

The users have access to two functions from package:

  1. fars_summarize_years

fars_summarize_years - creates a summary of number of accidents (from a vector of years) grouped by month and year.

fars_summarize_years(years=2014)
fars_summarize_years(c(2014, 2015))
  1. fars_map_state

fars_map_state draws a map (of state.num) with the positions (longitude and latitude) of accidents from a year. Here stat.num is a vector of length 1, representing the identification code for a state. (see state_code). Parameter year is a vector of length 1, representing the year when accidents was happened.

fars_map_state(state.num=24, year=2014)
fars_map_state(1, year=2015)


constantin345/minifars documentation built on May 7, 2019, 1:29 p.m.