fars_map_state: Draw a geographical map of accident sites for a specific US...

Description Usage Arguments Value Examples

View source: R/fars_functions.R

Description

fars_map_state() uses Base R graphics to plot the state boundary and accident site locations for the specified year.
The functions fars::make_filename, fars::fars_read and dplyr::filter are used to import data, and subset to a given state. The functions maps::map and graphics::points create the plot.
Values of LONGITUD > 900 or LATITUDE > 90 are treated as outliers and are not plotted.

Usage

1
fars_map_state(state.num, year, internal = TRUE)

Arguments

state.num

State number (in the sample data an integer, but based on the FIPS 2-character state numeric code). For example code 42 is Pennsylvania. The value should coerce to an integer.

year

Integer value representing year.

internal

Logical value indicating whether or not the package example data is used. Defaults to TRUE.

Value

Returns a map, or an error if data does not exist (for example, the year is invalid, or any of the variables STATE, LONGITUD and LATITUDE are not present).
The function checks for invalid states and parameters with no matching observations.
Note that some outlying states may raise an untrapped plotting error, for example state.num=2 (Alaska).

Examples

1
2
fars_map_state(1,2013) # Plots Alabama for 2013
fars_map_state(42,2013) # Plots Pennsylvania for 2015

rwpalin/fars documentation built on Nov. 5, 2019, 5:10 a.m.