fars_map_state: Map fatalities within a state for a given year.

Description Usage Arguments Details Value Note Examples

View source: R/fars_functions.R

Description

This function plots a map showing where traffic fatalitites occurred in a state, specified by argument state.num, for a given year, specified by argument year.

Usage

1
fars_map_state(state.num, year)

Arguments

state.num

an integer specifying which state you want to see traffic fatalities for.

year

a four digit integer representing the year you want to see traffic fatalities for.

Details

This function uses make_filename() and fars_read() to read in the .csv that corresponds with parameter year. Parameter state.num is coerced to be an integer and checked for valid existence. Logitudes of greater than 900 and latitudes of greater than 90 coerced into NAs. maps::map() is used to create the map. graphics::points() is used to plot traffic fatalities on the map.

Value

This function returns a map plot of the state fatalities in a year.

Note

If you supply an invalid state.num to this function, you'll receive error message: "invalid STATE number: ". If there are no traffic fatalities for the state and year, you'll receive a message: "no accidents to plot". Because this function coerces longitudes greater than 900 and latitudes greater than 90 to NA, you could receive a message saying, "nothing to draw: all regions out of bounds". fars_map_state(2, 2013) for example will return this message.

Examples

1
fars_map_state(48, 2015)

john-s-christensen/fars documentation built on May 17, 2019, 3 p.m.