Description Usage Arguments Details Value Examples
This function plots the geographic location of US highway fatalities for a
given year and state. You can adjust the plot by state (using the
state.num
argument) and year (using the year
argument).
1 | fars_map_state(state.num, year)
|
state.num |
A character string giving the text the function will print. |
year |
A character string or integer specifying a year (YYYY format). |
First, the function calls make_filename to create a valid file name format for the given year and then calls fars_read to read in the data based on the created file name. The function then checks to see if the state number selects is in the data. If it is not, an error is thrown indicating an invalid STATE number was entered. If the state number is valid but there are no rows of data for that state number, then a message stating there are "no accidents to report" is returned. If there are data for the valid state number, the function then creates a plot of the state selected and plots the highway fatalities as points on the map.
This function returns a graph of the state with points representing the geographic location of highway fatalities.
1 2 | fars_map_state(1, 2015)
fars_map_state(5, 2013)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.