
Last chance! 50% off unlimited learning
Sale ends in
A simplified alternative to source
,
which additionally sets some environment variables whilst
executing a series of expressions to ease debugging.
source2(file, local = FALSE)
This function returns nothing.
The function sets/updates the following environment variables while evaluating consecutive expressions:
__FILE__
-- path to the current file,
__LINE__
-- line number where the currently executed
expression begins,
__EXPR__
-- source code defining the expression.
The official online manual of realtest at https://realtest.gagolewski.com/
# \donttest{
# example error handler - report source file and line number
old_option_error <- getOption("error")
options(error=function()
cat(sprintf(
"Error in %s:%s.\n", Sys.getenv("__FILE__"), Sys.getenv("__LINE__")
), file=stderr()))
# now call source2() to execute an R script that throws some errors...
options(error=old_option_error) # cleanup
# }
Run the code above in your browser using DataLab