fars_map_state: 'fars_map_state' - Maps a given state's fatalities for a...

Description Usage Arguments Details Value Examples

View source: R/fars_functions.R

Description

fars_map_state - Maps a given state's fatalities for a given year using the maps package. If the state number or year are invalid given the current data, the function returns the appropriate error message.

Usage

1
fars_map_state(state.num, year)

Arguments

state.num

The two-digit state code of the area the user wants to map. State codes start from 01-51, and correspond to the alphabetical ordering of state names (e.g. 51 = Wyoming)

year

The year in which fatalities on the map will have occurred.

Details

The function uses other functions from this package to construct, for the given year, The appropriate file. It reads in that file, and converts the state number to an integer. Next, It checks to confirm the state code is valid. The data are trimmed to exclude values above 90 LAT or 900 Long (those are considered data collection errors, since coordinates are not defined past those thresholds). Lastly, the maps package function map is used to map the coordinates.

Value

Returns a map object showing the locations of the fatalities for the given state-year

Examples

1
2
3
4
5
## Not run: 
fars_map_state(04,2013)
fars_map_state(40,2014)

## End(Not run)

12mre1/fars documentation built on Oct. 30, 2019, 4:02 a.m.