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

Introduction

This package contains functions for reading, summarizing and visualizing the \href{Fatality Analysis Reporting System (FARS)}{https://www.nhtsa.gov/research-data/fatality-analysis-reporting-system-fars} data.

Note: for any of these functions to work, the FARS data must be located in your current working directory.

Loading Data

The \code{fars_read} function accepts a single argument, \code{filename}, which is a path to the FARS .csv file.

This example uses the sample data contained in the package.

filename <- system.file("extdata", "accident_2013_sample.csv", package="myRpackage", mustWork=TRUE)
fars_2013 <- fars_read(filename)

Summarizing Data

The \code{fars_summarize_years} function takes a vector of integers years and returns the total number of accidents for each month for a given year.

fars_summarize_years(c(2013, 2014))

Visualizing the FARS Data on a Map

The \code{fars_map_state} function takes two integer arguments, \code{state} and \code{year} for the state number.

fars_map_state(5, 2014)


csprock/myRpackage documentation built on Nov. 30, 2021, 8:03 a.m.