fars_map_state: Plot the geographic location of US highway fatalities

Description Usage Arguments Details Value Examples

Description

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).

Usage

1
fars_map_state(state.num, year)

Arguments

state.num

A character string giving the text the function will print.

year

A character string or integer specifying a year (YYYY format).

Details

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.

Value

This function returns a graph of the state with points representing the geographic location of highway fatalities.

Examples

1
2
fars_map_state(1, 2015)
fars_map_state(5, 2013)

jrwinget/Rfars documentation built on May 17, 2019, 12:11 a.m.