Description Usage Arguments Details Value Note Examples
View source: R/fars_functions.R
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.
1 | fars_read_years(years)
|
years |
A vector of years |
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.
This function returns an R list comprising of vectors (columns) of MONTH and year.
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.