R/Load_multiple_df.R

Defines functions load_multiple_df

Documented in load_multiple_df

#'  Loads and binds a dataframe divided in multiple files
#'
#' @return a string informing the user file format is the required one
#'
#' @importFrom  readr read_delim cols
#' @importFrom  dplyr tibble
#'
#' @param dirs, list of directories
#' @param delim, delimiter for read_delim
#' @param ..., other parameters to pass to read_delim
#'
#' @export

load_multiple_df = function(dirs, delim = '\t', ...) {
  df = lapply(dirs,
              function(x)
                tryCatch(
                  readr::read_delim(file = x, delim = delim, ...),
                  error = function(x)
                    dplyr::tibble()
                ))


  df = do.call(rbind, df)
  return(df)
}
CL-CHEN-Lab/User_interface_for_Kronos_scRT documentation built on Aug. 1, 2022, 2:08 p.m.