Description Usage Arguments Details Value Examples
View source: R/fars_functions.R
The function fars_map_state
reads the bz2 zipped file into R via the
functions make_filename
and fars_read
.
Converts the state.num to integers.
Checks whether the state number exists in the dataset - if not, it stops and
writes out the invalid state number. If the state number exists, the data is
filtered by this state.
If there are no observations for this state the message "no accidents to plot"
appears. Seems unnecessary, since there have to be observations due to the
previous check.
LONGITUD values which exceed 900 are corrected to NA.
The same logic is applied for LATITUDE values over 90.
Then, the locations of the accidents in that state are plotted.
1 | fars_map_state(state.num, year)
|
state.num |
A number, indicating the number of states for filtering |
year |
A string or number indicating the year for naming the file |
Errors occur if there are errors in make_filename
or fars_read
or the state.num cannot be converted to integer.
Additionally errors occur if the observations are out of bounds of the state.
A plot, showing the locations (longitud and latitude) of accidents in the chosen state and year
1 | # fars_map_state(state.num = 9, year = 2013)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.