fars_read_years: Load multiple years of FARS data

Description Usage Arguments Details Value See Also Examples

View source: R/fars_functions.R

Description

This function takes a vector of years, and returns a list of dplyr tibbles containting the FARS data for that year. The tibble contians only the month of the accident an the year in the format of the years vector. This is primarily a helper function for fars_summarize_years as much of the data contained in the files is lost.

Usage

1

Arguments

years

A vector of four-digit years of the FARS data to load. Currently only data from 2013-2015 are available. years must be coerceable to an integer, or else an error will be generated.

Details

Any component of years which does not correspond to a valid filename will produce a warning, but a list will still be returned, with NULL in position for each invalid component.

The FARS data can be found at the National Highway Traffic Safety Association here. 2013-2015 data is distributed with this package. The location of the files can be found using system.file('extdata',package='FARScoursera') These files need to be in your working directory for this function to work correctly.

Value

This function returns a list of dplyr tibbles containing FARS data for each year in years. The tibbles contain only the month and year of each accident, so the list is mostly of use as an input into other functions. If any element in years does not correspond to a valid FARS data file, a warning is generated and the corresponding component of the returned list is NULL

See Also

fars_read

Examples

1
2
3
## Not run: fars_read_years(2013:2015)
## Not run: fars_read_years(c('2013','2014','2015'))
## Not run: fars_read_years(2012:2016) # shows effect of invalid years in input

jmmark/FARScoursera documentation built on May 19, 2019, 1:54 p.m.