fars_map_state: Plot locations of motor vehicle crashes in a state for a...

Description Usage Arguments Value Examples

Description

This function (fars_map_state) accepts a single state number and a single year as input. The year is converted to a filename using the make_filename function from this package (make_filename). Motor vehicle crash data for the year is read using the fars_read function from this package (fars_read). The user input state number is converted to an integer. The user input state number is checked to see if it is in the list of unique state numbers detected in the data. An error message occurs if the user input state number is not detected in the data. A subset of the data with only the user input state number values is created using the filter function from the dplyr package (filter). A message is given if there are no motor vehicle crashes to plot. The value for the column LONGITUD is set to NA if it is greater than 900. The value for the column LATITUDE is set to NA if it is greater than 90. The motor vehicle accident locations based on the LONGITUD and LATITUDE columns are then plotted on a map of the state. The graphs are created using the map function from the maps package (map) and the points function from the graphics package (points).

Usage

1
fars_map_state(state.num, year)

Arguments

state.num

A string or integer giving the number of the state to plot motor vehicle crashes for.

year

A string or integer giving the year to plot motor vehicle crashes for.

Value

This function returns a map with the locations of of motor vehicle crashes in a state for a particular year. An error message occurs if the state or year input values are not valid

Examples

1
2
3
4
5
6
## Not run: 
fars_map_state(1, 2013)
fars_map_state("1", "2013")
fars_map_state(state.num=1,year=2013)

## End(Not run)

drsmd23/Fars documentation built on May 15, 2019, 2:54 p.m.