fars_read_years: Reading FARS files

Description Usage Arguments Value Note Source Examples

Description

Reading FARS files from working directory with given YEARS argument into tbl_df object of dplyr package. Returns data from which all variables(columns) except YEAR and MONTH are removed. After reading the files dplyr with pipes(magrittr) are used to create new column year, and then remove all columns, except MONTH and YEAR.

Usage

1

Arguments

years

A vector of years, provided as a character vector or as an integer vector. Provide the years in 4-digit format to ensure the correct file can be found for that year. If any of the years is absent from the FARS dataset, a NULL value is returned for that year. Files need to be in working directory.

Value

A list of tibble data-frames containing the FARS dataset for each year in the input set. The entry is NULL for any year that is absent from the FARS dataset.

Note

Function use make_filename(year) and fars_read(year) functions, and readr, dplyr and magrittr packages.

Source

Coursera, Building R Packages

Examples

1
2
3
4
5
setwd(dirname(system.file("extdata","accident_2013.csv.bz2",package = "fars")))
fry<-fars_read_years(c(2013))
str(fry)
summary(fry)
fry[1]

krzyklo/fars documentation built on May 19, 2019, 8:23 a.m.