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 callfooyour inner function, thendebugonce(foo)will launch the debugger only the first time thatfoois called, whenx==1.2)
debugandundebug. After you rundebug(foo), the debugger will be launched every timefoois called, and until you runundebug(foo):When you want to stop debugging
foo, typeundebug(foo)before hittingcand it will take you back to the first level browser.