fars_read_years: FARS Read years.

Description Usage Arguments Details Value Depends on Examples

View source: R/fars_functions.R

Description

Reads the FARS data file(s) for the provided years in R as data frame table(s) and, for each one of them, keeps only the MONTH and year variables.

Usage

1

Arguments

years

A vector containing the years of interests as integer or character.

Details

For each provided year the following steps are executed:

  1. Build the FARS file name from year (using make_filename).

  2. Read the FARS data file in R as a data frame table (using fars_read).

  3. Add a year variable to the data frame table.

  4. Keep MONTH and year variables only from the data frame table.

The data file names must be compliant with FARS pattern name. The data files must be located in the working directory. If a file does not exist in the working directory the associated data is set to NULL.

Value

A list containing the selected data as a data frame table (see tbl_df in the dplyr package) for each provided year.

Depends on

  1. mutate and select in the dplyr package.

Examples

1
2
3
4
5
## Not run: 
fars_read_years(c(2013, 2014, 2015))
fars_read_years(c("2013", "2014", "2015"))

## End(Not run)

pparacch/fars documentation built on May 6, 2019, 6:01 p.m.