fars_read: Import traffic accident data

Description Usage Arguments Details Value Note Examples

View source: R/fars_functions.R

Description

Enables the importing of comma delimited text files (CSV) or tab sperated files (TSV) from the US National Highway Traffic Safety Administration's Fatality Analysis Reporting System (FARS). The data provides a statistical summary of fatalities (where a death occured within 30 days of the incident) suffered in motor vehicle accidents in the United States.

Usage

1
fars_read(filename)

Arguments

filename

A character vector giving the location of the data file to be imported.

Details

The function uses the the readr package to read and load the csv file identified by the filename parameter. The tbl_def function returns a tibble otherwise execution of the function stops and a warning ' file accident_xxxx.csv.bz2 does not exist' is issued (where xxxx is the year of data being imported). The suppressmessages function is used to ignore all simple diagnostic messages.

Value

A 50 column tibble with each row representing a fatal incident.

Note

The readr and dplyr packages must be installed in the R environment but do not have to be attached.

Examples

1
2
fars_read('accident_2013.csv.bz2')
fars_read('accident_2014.csv.bz2')

gben1750/fatal-car-analysis-reporting-system documentation built on Dec. 20, 2021, 9:49 a.m.