library(dplyr)
library(maps)
library(readr)
library(tidyr)
source("../R/fars_functions.R")

Building.an.R.package provides three categories of important functions regarding FARS: Reading in, Summarizing, and Plotting.

Reading in

Complete files

For reading the complete file use: fars_read. It reads a CSV file and creates a tibble from it. Specify the filename using the filename argument.

accident_2013 <- fars_read("accident_2013.csv.bz2")
head(accident_2013)

Filter by year

The fars_read_years function returns a list of tibbles consisting of two columns: MONTH and year.

accident_2013_to_2015 <- fars_read_years(2013:2015)
head(accident_2013_to_2015)

Summarizing

The fars_summarize_years function counts accidents for the specified years, grouped by months.

fars_summarize_years(2013:2015)

Plotting

building.an.R.package is able to plot the FARS data for the specified state in the specified year using the fars_map_state function.

fars_map_state(1, 2013)


Davidovich4/building.an.R.package documentation built on May 29, 2019, 2:08 p.m.