5.12 Fixing errors: Interactive debugger

  • When do we use?

    • You have identified the error using traceback and want to figure out what’s causing it.
  • Use the interactive debugger to debug your code

  • Two ways to launch the debugger:

  • Add a call to browser() in your source code

  • This can also be done using a conditional statement

if (input$value == "a") {
  browser()
}
# Or maybe
if (my_reactive() < 0) {
  browser()
}
  • Add an RStudio breakpoint by clicking to the left of the line number

5.12.1 Useful interactive debugger commands

Use these when you the debugger is up and running:

n - next step in the function

c - leaves debugger, continues the regular execution of the function

Q - stops debugging, terminates the function, and returns to global workspace