Learn R Programming

Smisc (version 0.3.9.1)

sourceDir: Sources all files with '.R' or '.r' extensions in a directory

Description

Sources all files with '.R' or '.r' extensions in a directory using a try-catch for each file

Usage

sourceDir(directory, recursive = FALSE, tryCatch = TRUE, ...)

Arguments

directory

Character string indicating the path of the directory containing the R files to be sourced.

recursive

=TRUE descends into subdirectories of directory

tryCatch

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

Value

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.

Details

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.