fars_read_years: Reading the bz2 zipped files with corresponding year in their...

Description Usage Arguments Details Value Examples

View source: R/fars_functions.R

Description

The function fars_read_years can load several files corresponding to their year into R, since it gets a list/vector of years as input and returns the month and years of that dataframes. It is still possible to only load one dataset and manipulate it. The lapply functionality allows to create for each element (year of years) the zipped file name, check whether it exists with tryCatch and if it throws an error, write out a warning that the year is invalid and return NULL. If the file exists, the inner of tryCatch is executed and the data is loaded into R. Then a new column year is created, which is the current element of years chosen in lapply and only Month and year of the dataset are selected.

Usage

1

Arguments

years

A list/vector containing the years for which data should be loaded and month + year are extracted

Details

Errors occur in the same cases as for make_filename, but not for fars_read, since this is part of the tryCatch.

Value

A dataframe containing the month and the year of each observation of the zipped file - the year coming as input and has to be part of the file name.

Examples

1
# fars_read_years(2013)

alex2905/coursera documentation built on May 17, 2019, 8:04 a.m.