R/get_data.R

Defines functions get_data

Documented in get_data

#' Helper function to load data into memory
#'
#' @param path character: Path to .parquet file
#' @param filetype character: filetype to be read
#'
#' @return data.frame
#' @export
#'
get_data <- function(path,
                     filetype = c("rds", "fst", "qs", "parquet")) {

  filetype <- match.arg(filetype)
  if (filetype == "parquet") {
  out <- arrow::read_parquet(path)
  } else if (filetype == "qs") {
    out <- qs::qread(path)
  } else if (filetype == "fst") {
    out <- fst::read_fst(path)
  } else {
    out <- readRDS(path)
  }

  return(out)
}
PIP-Technical-Team/testPackage documentation built on March 25, 2021, 10:41 a.m.