fars_read_years: Read FARS data for a vector of years

Description Usage Arguments Value Examples

View source: R/fars_functions.R

Description

fars_read_years() reads multiple years' data using fars::make_filename and fars::fars_read.
Note that only the year and MONTH variables are kept, therefore the output is most suitable for counting observations read in.

Usage

1
fars_read_years(years, internal = TRUE)

Arguments

years

Integer vector containing one or more years for which data exists.

internal

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

Value

Returns a list the same length as the input, with each element corresponds to a year.
Years successfully read generate a n x 2 tibble where n is the number of data rows imported, and the columns are 'MONTH' (an integer 1 to 12) and 'year'.
An element is NULL if a year is invalid, or the 'MONTH' variable is not present in the data.
This function is called by fars::fars_summarize_years, and is most useful in that context.

Examples

1
2
3
df1 <- fars_read_years(2013)
df2 <- fars_read_years(2013:2015)
fars_read_years(2012) # Returns 'invalid year'

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