R/source_directory.R

Defines functions source_directory

Documented in source_directory

#' Source all scripts in a directory
#'
#' Source all scripts in a directory
#' @param dir the directory you want to source
#' @keywords source
#' @export
#' @examples
#' source_directory(here::here("R"))

source_directory <- function(dir){
  assertthat::assert_that(
    assertive::is_dir(dir),
    msg = "The string you supplied as the dir argument in source_directory() does not represent a valid directory"
  )

  files <- fs::path(dir, list.files(dir))
  purrr::walk(files, source)
}
Kidapt/keda documentation built on Nov. 23, 2019, 3:35 a.m.