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

Aims of the package

This package allows you to make a map of every state and to put pointers on it based on geographical positions of accidents occurred in a given year. It takes data sets from US National Highway Traffic Safety Administration's Fatality Analysis Reporting System and after reading them into R, it calculates the number of accidents per month for every year and then generates a map of the given state based on state.num and year arguments.

Summarize number of accidents

You can calculate the number of accidents in every month per year by running fars_summarize_years:

library(dplyr)
setwd(system.file("extdata", package = "fars"))
fars_summarize_years(c(2013, 2014, 2015))

Draw map with pointers

In order to make a map of every state with pointers indicating geographical positions of accidents across the state you can run the following function:

setwd(system.file("extdata", package = "fars"))
fars_map_state(48, 2015)


AnoushiravanR/fars documentation built on Jan. 19, 2021, 5:16 p.m.