Description Usage Arguments Value See Also Examples
View source: R/fars_functions.R
'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.
1 | fars_map_state(state.num, year)
|
state.num |
A two-digit FIPS state numeric code |
year |
A four-digit number representing a year |
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.
fars_read
and make_filename
,
which this function wraps
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.