fars_read: Read csv and compressed csv data from FARS

Description Usage Arguments Details Value Note See Also Examples

View source: R/fars_functions.R

Description

This function reads csv-format and compressed csv-format data files from the Fatality Analysis Reporting System (FARS) of the US National Highway Traffic Safety Administration. FARS is a yearly, nationwide census of fatal injuries resulting from motor vehicle traffic crashes.

Usage

1
fars_read(filename)

Arguments

filename

A path to the csv-format FARS file, or a connection to it. The function uncompresses any filenames ending in .gz, .bz2, .xz, or .zip, and downloads any filenames begining with http://, https://, ftp://, or ftps://.

Details

The function expects that data match the default csv formatting options applied by read_csv. Please see the readr package documentation for more details. The function outputs the data in tibble format. Please see the dplyr package for details on that format.

Value

The function returns FARS data in tibble format.

Note

The function will generate an error if the file cannot be found by R.

See Also

read_csv

Examples

1
2
3
4
5
6
7
8
# Read bz2-compressed FARS data
# from a file in the inst/extdata of the
# FARSight package named
# "accident_2013.csv.bz2".
FARSdt <-  fars_read(make_filename(2013))

# Convert output to data frame
FARSdf <- as.data.frame(FARSdt)

ChardingRes/FARSight documentation built on May 21, 2017, 6:32 a.m.