fars_read: Load a file from the FARS database

Description Usage Arguments Details Value See Also Examples

View source: R/fars_functions.R

Description

A function for loading the FARS data as specified by filename. If filename exists it returns the data as a dplyr tbl_df. If it does not exist, it stops with an error.

Usage

1
fars_read(filename)

Arguments

filename

A string containing the filename to be read from the FARS data. be sure to include a valid path if the data are not in the current working directory. See details below for finding the data

Details

The FARS data can be found at the National Highway Traffic Safety Association here. If you choose to download it directly, be sure to include the correct path to the data.

Data for 2013-2015 are included in the distribution of this package in the extdata directory. To find it, use the system.file() function. For example, system.file('extdata','accident_2013.csv.bz2',package = 'FARScoursera')

Value

This function returns a dplyr tibble containing the data. If filename is not valid, the function stops with an error message

See Also

make_filename for convenient creation of valid filename input

Examples

1
2
3
4
## Not run: fars_read('accident_2013.csv.bz2')
fars_read(system.file('extdata','accident_2013.csv.bz2',package = 'FARScoursera'))
## Not run: fars_read(make_filename(2013)
## Not run: fars_read('not_a_valid_file') #shows the expected errors

jmmark/FARScoursera documentation built on May 19, 2019, 1:54 p.m.