Description Usage Arguments Value Note Source Examples
The accident locations are plotted on the map of STATE given as input argument (integer). Function checks whether there is such STATE for given YEAR, and throws "invalid STATE number" if it is missing. If there are no accidents for given state, then "no accidents to plot" information is presented. Read single FARS file from working directory with given YEAR argument into tbl_df objects.
1 | fars_map_state(state.num, year)
|
state.num |
the index number of a state as an integer corresponding to a required state. The function throws an error if no fatality information is available for the requested state in the FARS data for the requested year. |
year |
A |
NULL return value. The function plots a graph as a side-effect If no accidents were observed in the state/year, no map is plotted.
State number 2 do not work: "nothing to draw: all regions out of bounds". Possible bug
If LONGITUD is bigger than 900 or LATITUDE bigger than 90, their value is set to NA.
Function uses make_filename(year) and fars_read(year) functions, and readr, dplyr, and maps packages.
See also fars_read
Coursera, Building R Packages
1 2 3 | ## Not run: fars_map_state(44,2013)
## Not run: fars_map_state(2,2015) # do not works for this year and 2013,2014 as well.
## Not run: #Returns: nothing to draw: all regions out of bounds
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.