Continue executing after browser()

前端 未结 1 987
礼貌的吻别
礼貌的吻别 2021-01-23 05:53

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

相关标签:
1条回答
  • 2021-01-23 06:17

    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
    
    0 讨论(0)
提交回复
热议问题