R/source_dir.R

Defines functions source_dir

Documented in source_dir

#' Source all R files in a given directory.
#'
#' This function sources all R files in a given directory.
#' @param path Path to directory.
#' @param trace Defaults to TRUE.
#' @param ... Other arguments.
#' @export
#' @examples
#' source_dir('filePath')

source_dir <- function(path, trace = TRUE, ...) {
    for (nm in list.files(path, pattern = "\\.[RrSsQq]$")) {
        if (trace) cat(nm, ":")
        source(file.path(path, nm), ...)
        if (trace) cat("\n")
    }
}
jhelvy/jhelvyr documentation built on May 17, 2023, 8:46 p.m.