fars_map_state: Plot Geographical Mapping of FARS Crash Location data by...

Description Usage Arguments Value See Also Examples

View source: R/fars_functions.R

Description

'fars_map_state()' function plots geographic distribution of FARS fatal traffic crash locations at individual state level. The function reads in FARS data of the particular state and year specified in the arguments, which includes the accidents’ geographical coordinates. The function then calls map to draw the map of the state, an outlined polygon selected from the geographical database of USA state via the xlim and ylim arguments derived from accidents’ longitude and latitude ranges. Lastly it calls points function to add the points mapping to all non NA coordinates in the data to the state map.

Usage

1
fars_map_state(state.num, year)

Arguments

state.num

A two-digit FIPS state numeric code

year

A four-digit number representing a year

Value

The result or side-effect of map and points. Invalid state.num, which has no match in STATE column of FARS data, will cause function to stop execution and result in "invalid STATE number: ..." error. Missing data for the state and year as specified in the arguments will result in a warning message "no accidents to plot" and (temporarily) an invisible NULL object to be returned.

See Also

fars_read and make_filename, which this function wraps

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
fars_map_state(state.num=36, year=2013) # New York

## End(Not run)
## Not run: 
pdf(file="2015_STATE06.pdf")
fars_map_state(06, year=2015)  # California
dev.off()

## End(Not run)

johnxz/farsr documentation built on Dec. 21, 2021, 2:14 a.m.