R/fars_read.R

Defines functions fars_read

Documented in fars_read

#' fars_functions
#'
#' Reads data from a delimited file and returns it as a data frame.
#'
#' @param filenmae A character string containing the path and name of the file to read.  Remeber to include a path if the file is not in the current directory.
#'
#' @return Returns a data frame
#'
#' @importFrom dplyr tbl_df
#' @importFrom readr read_csv
#'
#' @examples fars_read('../data/accident_2013.csv.bz2')
#'
#' @note Returns an error if the file does not exist.
#'
#' @export
fars_read <- function(filename) {
  if(!file.exists(filename))
    stop("file '", filename, "' does not exist")
  data <- suppressMessages({
    readr::read_csv(filename, progress = FALSE)
  })
  dplyr::tbl_df(data)
}
ekawabata/BuildingAnRPackage documentation built on May 31, 2020, 12:32 a.m.