Description Usage Arguments Details Value Note Examples
View source: R/fars_functions.R
This function plots a map showing where traffic fatalitites occurred in a state,
specified by argument state.num
, for a given year, specified by argument
year
.
1 | fars_map_state(state.num, year)
|
state.num |
an integer specifying which state you want to see traffic fatalities for. |
year |
a four digit integer representing the year you want to see traffic fatalities for. |
This function uses make_filename()
and fars_read()
to read in the
.csv that corresponds with parameter year
. Parameter state.num
is
coerced to be an integer and checked for valid existence.
Logitudes of greater than 900 and latitudes of greater than 90 coerced into NAs.
maps::map()
is used to create the map. graphics::points()
is
used to plot traffic fatalities on the map.
This function returns a map plot of the state fatalities in a year.
If you supply an invalid state.num
to this function, you'll receive error
message: "invalid STATE number: ". If there are no traffic fatalities for the
state and year, you'll receive a message: "no accidents to plot".
Because this function coerces longitudes greater than 900 and latitudes
greater than 90 to NA, you could receive a message saying, "nothing to draw:
all regions out of bounds". fars_map_state(2, 2013)
for example will
return this message.
1 | fars_map_state(48, 2015)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.