R/fars_read.R

#' Import a tibble
#'
#' This is a simple function that returns csv format data as a tibble.
#' In case the file (as specified by \code{filename} doesn't exist the function
#' throws an error)
#'
#' @param filename A character string that specifies the path to the data file
#'
#' @return The function returns tibble data object
#'
#' In case the file path that as specified by \code{filename}
#' doesn't exist the function throws an error
#'
#'
#' @export
#'
fars_read <- function(filename) {
  if(!file.exists(filename))
    stop("file '", filename, "' does not exist")
  data <- suppressMessages({
    readr::read_csv(filename, progress = FALSE)
  })
  tibble::as.tibble(data)
}
MichaelGurkov/FinalProjectFars documentation built on May 13, 2019, 1:21 p.m.