Sometimes you throw multiple browsers into a function to debug. I know you can exit the whole shebang with Q but what if you want to exit the second browser (see below's code) and return to the first level of browser? I've heard type c but that doesn't exit the second level browser.
FUN <- function() {
browser() #first one
lapply(1:10, function(x) {
browser() #second one
return(x)
})
}
FUN()
I agree with Josh and would like to suggest these two alternatives to your current code:
1) debugonce: If we call foo your inner function, then debugonce(foo) will launch the debugger only the first time that foo is called, when x==1.
FUN <- function() {
browser()
foo <- function(x)return(x)
debugonce(foo)
lapply(1:10, foo)
}
2) debug and undebug. After you run debug(foo), the debugger will be launched every time foo is called, and until you run undebug(foo):
FUN <- function() {
browser()
foo <- function(x)return(x)
debug(foo)
lapply(1:10, foo)
}
When you want to stop debugging foo, type undebug(foo) before hitting c and it will take you back to the first level browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With