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

This vignette describes the step necessary to import and use FARS data.

There's not much to say about how to use it:

library(fars)

# use sample fars file included in the package 
sample <- system.file("extdata", "accident_2014.csv.bz2", package = "fars")

head(fars_read(sample))

Create filenames from year input

In order to create a filename in the correct format, make_filename function can be used:

library(fars)
library(magrittr)
file_2013 <- make_filename(2013)
file_2013 <- paste0(system.file("extdata", package = "fars"), "/",file_2013)

Reading the file

The filename created above can be read using fars__read function:

fars_read(file_2013)

Data summary

Summary of fatalities as a function of month and year can be seen using fars_summarize_years function:

fars_summarize_years(2013)

Map of fatalities

Fatalities for a given state and year can be seen on a map using fars_map_state function:

fars_map_state(1, 2013)


dragosmg/fars documentation built on Sept. 18, 2021, 11:19 p.m.