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

This helps in simple exploration of the data from the US National Highway Traffic Safety Administration (NHTSA) Fatality Analysis Reporting System (FARS). This is an assignment work for the "Building R Packages" course on Coursera, as part of the Johns Hopkins University "Mastering Software Development in R" specialization.

Data source

The data in this package come 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.

The files should be named: 'accident_YEAR.csv.bz2', where YEAR is a a year number, for example for data for 2015: 'accident_2015.csv.bz2'.

In order to load the data

fname <- make_filename(2013)
data_2013 <- fars_read(fname)
head(data_2013)

In order to read multiple datasets ``` {r, eval = FALSE} data.list <- fars_read_years(c(2013, 2014, 2015))

The code returns a list of tibbles.

## Summarising
The package enables quick summary of the data. In order to do so you can use fars_summarize_years() function. It takes a year (or vector of years) as an argument and returns a tibble summarising number of cases per month and year.
``` {r, eval = FALSE}
fars_summarize_years(2013:2015)

Plotting map

Finally, farsData package enables plotting map of cases in one state using maps package. To do so, you can use fars_map_state() function. It takes a year and a state number as arguments.

fars_map_state(36, 2014)


LapsedPacifistROU/FARSAssignment documentation built on May 7, 2019, 3:12 p.m.