R/fars_read.R

#' Import Data
#'
#' Takes a character vector, containing file name or path and load it.
#'
#' @param filename Character vector.
#'
#'
#' @details This function would work using the packages: \bold{readr} & \bold{dplyr}.
#'
#' @note The data will be import only if the file exists.Here ‘exists’ is in the sense of the system's stat call: a file will be reported as existing
#'       only if you have the permissions needed by stat. Existence can also be checked by file.access, which might use different permissions and so obtain a different result.
#'      Note that the existence of a file does not imply that it is readable
#'
#' @return  A tbl_df containing a representation of the data in the file.
#'
#' @importFrom readr read_csv
#' @importFrom dplyr tbl_df
#' @importFrom magrittr %>%
#'
#' @examples
#' \dontrun{fars_read(filename)}
#'
#' @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)
}
AlphaIgor/Test documentation built on May 19, 2019, 10:47 p.m.