preRunSetupProject parses an R script (default: "global.R") and evaluates its contents up to the setupProject() call, either fully or partially based on the upTo argument. This is useful for initializing only certain parts of a project without executing the entire setup.

preRunSetupProject(file = "global.R", upTo = TRUE, envir = parent.frame())

Arguments

file

Character string. Path to the R script containing the setup code. Defaults to "global.R".

upTo

Character or logical. If TRUE, evaluates all code up to and including the first setupProject() call within file. If a character string, only evaluates the code up to the setupProject plus the arguments up to the upTo named argument. Defaults to "paths" so that paths will be evaluated and availble to use.

envir

The environment where the function should be finding objects. Defaults to parent.frame() so it can find them in the calling frame.

Value

The evaluated result of the executed portion of setupProject(). i.e., a list returned by setupProject().

Details

The function:

  1. Parses the specified file using parse().

  2. Identifies the line where setupProject() is called.

  3. Evaluates all code before the setupProject() call.

  4. Depending on upTo, evaluates either the full call or a subset of its arguments.

This allows selective initialization of project components for debugging or partial setup in large projects.

See also

Examples

if (FALSE) { # \dontrun{
# Run file up to and including the setupProject, but only to the 'paths' argument
result <- preRunSetupProject(file = "global.R", upTo = "paths")

# Run file up to and including full setupProject()
result <- preRunSetupProject(file = "global.R", upTo = TRUE)
} # }