knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(dplyr)
library(readr)
library(tidyr)
library(maps)

This describes some of the features of this package. Reads data from FARS, a nationwide database of reported wrecks and fatalitits on public roads.

Read in the data

Code was built to look through three of the provided data sets and return the matching file. It will then read the file and return a table.

library(fars)
t <- system.file("extdata", "accident_2013.csv.bz2", package="fars") 
fars_read(t)

Create a file name

This function creates the file name when given year as input.

This function returns a character string with coding "accident_year.csv.bz2"

make_filename(2013)

Read Data & Summarize

This function makes data frames with MONTH and year columns

When passing the function a list of valid years as input, it gets associated files, For each file it retrieves the corresponding data table and selects the MONTH and year columns.

This function returns a list of tables corresponding to list of years.

fars_read_years(c(2013, 2014, 2015))

Summarize Years

This function receives a list of years as an input and gets data tables with \code{fars_read_years} Then it summarizes the results per year.

Map it out

This function gets passed a specific state and year, then gets associated data. If the state exists, it filters the data per state and plots accidents for that state.

fars_map_state(state.num=1,year=2013)


jluthy/Demo-fars_functions documentation built on May 13, 2019, 5:24 p.m.