Description Usage Arguments Value Note Examples
View source: R/fars_functions.R
The "fars_map_state" function reads yearly data of FARS datasets,
filters the data to the given state number, and plots the accidents based on
their geographic locations (latitude, longitude). You can customize the state
number and the years of which you want to plot (using the state.num
and
year
arguments). The function uses the "make_filename" and the
"fars_read" functions to read the datasets for the year specified, then filters
the data for the given state number, and plots the accidents to a map of
the specific state based on the locations of accidents.
1 | fars_map_state(state.num, year)
|
state.num |
A number describing the state to plot |
year |
A number describing the year to plot |
This function returns a map plot of a given state visualizing the accidents based on their location
There is an "if" statement verifying that the given state.num
is a valid state number. Stops if it's invalid. Additionally,
another "if" statement checks if the state-filtered dataset
contains any accidents. If it's empty, gives an error message and
stops with an invisible NULL result.
1 2 3 4 5 | ## Not run:
fars_map_state(1, 2013)
fars_map_state(8, 2015)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.