fars_read: Read a FARS query into a tibble

Description Usage Arguments Details Value See Also Examples

View source: R/fars_functions.R

Description

fars_read() takes in a *.csv file from the NHTSA's FARS #' archives and returns a tibble.

Usage

1
fars_read(filename)

Arguments

filename

Relative filepath to the current working directory. This must be an existing comma separated values file (*.csv) or it will throw an error.

Details

This function takes in a *.csv file and using the readr package will load the file as a tibble then will return it as a tbl_df (subclass of a data.frame) through dplyr. This function is ideally to be used with the FARS (Fatality Analysis Reporting System) archives for accident data in *.csv format. If no file exists an error will occur before attempting to read the file.

Value

A tibble from the inputted *.csv file.

See Also

https://www.nhtsa.gov/file-downloads?p=nhtsa/downloads/FARS/ for other .csv files from FARS (Fatality Analysis Reporting System) to process. Explore the NHTSA's website for more information on the FARS program.

Other FARS functions: fars_map_state(), fars_read_years()

Examples

1
2
3
4
5
6
# this will stop
## Not run: fars_read("this_file_does_not_exist.csv") 
#returns data as tbl_df
 #setwd(system.file("data-raw", package = "wk4package"))
 #getwd()
 ## Not run: fars_read("accident_2013.csv.bz2") 

SamHall14/wk4package documentation built on Dec. 18, 2021, 12:56 p.m.