fars_map_state: Plot accidents to a map of a specific state for a given year.

Description Usage Arguments Value Note Examples

View source: R/fars_functions.R

Description

The "fars_map_state" function reads yearly data of FARS datasets, filters the data to the given state number, and plots the accidents based on their geographic locations (latitude, longitude). You can customize the state number and the years of which you want to plot (using the state.num and year arguments). The function uses the "make_filename" and the "fars_read" functions to read the datasets for the year specified, then filters the data for the given state number, and plots the accidents to a map of the specific state based on the locations of accidents.

Usage

1
fars_map_state(state.num, year)

Arguments

state.num

A number describing the state to plot

year

A number describing the year to plot

Value

This function returns a map plot of a given state visualizing the accidents based on their location

Note

There is an "if" statement verifying that the given state.num is a valid state number. Stops if it's invalid. Additionally, another "if" statement checks if the state-filtered dataset contains any accidents. If it's empty, gives an error message and stops with an invisible NULL result.

Examples

1
2
3
4
5
## Not run: 
fars_map_state(1, 2013)
fars_map_state(8, 2015)

## End(Not run)

Solymi90/Fars.Assignment documentation built on May 27, 2019, 7:24 a.m.