Skip to contents

Executes an R script within a sandbox directory, suppressing messages, warnings, and graphical output. This is useful for testing empirical analysis scripts without polluting the console or creating unwanted plots.

Usage

run_in_sandbox(
  script_path,
  sandbox = NULL,
  suppress_messages = TRUE,
  suppress_warnings = TRUE,
  capture_output = TRUE
)

Arguments

script_path

Path to the R script to execute.

sandbox

Optional. A sandbox object created by setup_sandbox(). If NULL (default), uses the most recently created sandbox.

suppress_messages

Logical. Whether to suppress messages (default: TRUE).

suppress_warnings

Logical. Whether to suppress warnings (default: TRUE).

capture_output

Logical. Whether to capture output (default: TRUE).

Value

Invisible TRUE on successful execution.

Examples

with_example({
  sandbox <- setup_sandbox()
  on.exit(cleanup_sandbox(sandbox), add = TRUE)
  run_in_sandbox("analysis.R", sandbox)
})