I\'m debugging R code with browser(). The function pauses the execution of the current R script and allows for inspection. Is it possible to enable/disable the debug mode on the
Your question prompted me to read ?browser
. The documentation says you can use the expr=
argument to browser
to create (the illusion) of conditional debugging. That, combined with a global option should give you what you want.
foo <- function(x) {
browser(expr=isTRUE(getOption("myDebug")))
mean(x)
}
foo(1:10)
options(myDebug=TRUE)
foo(1:10) # invokes browser