fars_read_years: Read FARS Data for Multiple Years

Description Usage Arguments Details Value Note Examples

Description

This function takes a vector of years as its only parameter, reads the FARS files for those years and returns the MONTH and year columns as a list. It is an internal (supporting) function used by other functions in this package.

Usage

1

Arguments

years

A vector of years

Details

This function processes each element of a vector or list of years as follows: - calls the supporting function, make_filename(), to generate a filename with the year, - calls the supporting function, fars_read(), to read the FARS data file with the generated filename, - if the file exists: creates a new column, year, selects the MONTH and year columns, and adds them to an R list. - If the file does not exit: gives a warning message, and adds nothing (NULL) to the list. - Returns the R list to the calling function.

Value

This function returns an R list comprising of vectors (columns) of MONTH and year.

Note

Following functions need to be imported: dplyr package: select() and mutate() Catches any execution error in a generic error() function and ignores that invalid year by returing a NULL.

Examples

1
2
3
4
5
6
## Not run: 
fars_read_years(c(2014, 2015, 2016))
fars_read_years(2014:2016)
fars_read_years(list(2014, 2015, 2016))

## End(Not run)

masabri01/BuildingRPackagesCoursera documentation built on May 21, 2019, 12:39 p.m.