fars_map_state: Plotting the locations of accidents for one state in one year...

Description Usage Arguments Details Value Examples

View source: R/fars_functions.R

Description

The function fars_map_state reads the bz2 zipped file into R via the functions make_filename and fars_read. Converts the state.num to integers. Checks whether the state number exists in the dataset - if not, it stops and writes out the invalid state number. If the state number exists, the data is filtered by this state. If there are no observations for this state the message "no accidents to plot" appears. Seems unnecessary, since there have to be observations due to the previous check. LONGITUD values which exceed 900 are corrected to NA. The same logic is applied for LATITUDE values over 90. Then, the locations of the accidents in that state are plotted.

Usage

1
fars_map_state(state.num, year)

Arguments

state.num

A number, indicating the number of states for filtering

year

A string or number indicating the year for naming the file

Details

Errors occur if there are errors in make_filename or fars_read or the state.num cannot be converted to integer. Additionally errors occur if the observations are out of bounds of the state.

Value

A plot, showing the locations (longitud and latitude) of accidents in the chosen state and year

Examples

1
# fars_map_state(state.num = 9, year = 2013)

alex2905/coursera documentation built on May 17, 2019, 8:04 a.m.