fars_map_state: Create a map of FARS accidents in a particular state

Description Usage Arguments Details Value Examples

View source: R/fars_functions.R

Description

This function returns a map showing the geographic locations of all of the accidents in the FARS database in a particular state for a particular year. Each accident is a dot in the outline of the state

Usage

1
fars_map_state(state.num, year)

Arguments

state.num

A scalar of a type that can be coerced to an integer of the integer identifier of the state. A list of the state identifying integers for the FARS data can be found here. If state.num is not coercible to an integer or if the resulting integer is not a valid state ID in FARS, an error will be thrown

year

A scalar four-digit year of a type that can be coerced to integer representing the year of data to be mapped. Currently, only the years 2013-2015 are in the data. If year cannot be coerced to integer or if it does not refer to a valid four-digit year in the data, an error will be thrown

Details

The FARS data can be found at the National Highway Traffic Safety Association here. 2013-2015 data is distributed with this package. The location of the files can be found using system.file('extdata',package='FARScoursera') These files need to be in your working directory for this function to work correctly.

Value

This function returns a graphical map of the locations of all of the accidents in the FARS database in the given state in the given year. Each accident is a dot, and state outlines are shown. If either state.num or year cannot be coerced to integer or do not refer to a valid identifier, an error is thrown instead

Examples

1
2
## Not run: fars_map_state(1,2015)
## Not run: fars_map_state(6,2013)

jmmark/FARScoursera documentation built on May 19, 2019, 1:54 p.m.