Sources all files with '.R' or '.r' extensions in a directory using a try-catch for each file
sourceDir(directory, recursive = FALSE, tryCatch = TRUE, ...)
Character string indicating the path of the directory containing the R files to be sourced.
=TRUE
descends into subdirectories of
directory
if TRUE
, sourcing is protected in a try catch, i.e.,
if there is an error, sourceDir
will continue to the next file. If
FALSE
, sourceDir
will stop if a file sources with an error.
Additional arguments to source
Invisibly returns a character vector containing the files that were identified for sourcing. Also prints a message indicating whether each file was sourced correctly or not.
In addition to sourcing files for general use, this function is also useful in package development to verify there are no syntax errors prior to building and compilation.