R/sourceRFunctions.R

Defines functions sourceRFunctions

sourceRFunctions <- function(dir, local = FALSE) {
  # Source all .R files in a directory
  #
  # Arguments:
  #   dir {string} -- directory with .R files to source
  #   local {bool} -- 'local' parameter passed into `source()` function
  #
  # Returns:
  #   nothing

  if(!dir.exists(dir)) { message(sprintf("'%s' does not exist", dir)); return(NULL) }
  RFunctions = list.files(path=dir, pattern="\\.(R|r)", full.names=TRUE)
  if(!length(RFunctions)) { return(NULL) }
  for(fn in RFunctions) source(fn, local=local)
}
tsouchlarakis/rdoni documentation built on Sept. 16, 2019, 8:53 p.m.