Skip to content

Instantly share code, notes, and snippets.

@nassimhaddad
Last active December 11, 2015 03:48
Show Gist options
  • Save nassimhaddad/4539982 to your computer and use it in GitHub Desktop.
Save nassimhaddad/4539982 to your computer and use it in GitHub Desktop.
debugging process in R

Routine:

  1. When an error occurs, the first thing that I usually do is look at the stack trace by calling traceback(): that shows you where the error occurred, which is especially useful if you have several nested functions.
  2. Next I will set options(error=recover); this immediately switches into browser mode where the error occurs, so you can browse the workspace from there.
  3. If I still don't have enough information, I usually use the debug() function and step through the script line by line.

Notes:

  • traceback() # shows the stack at the time of the last error
  • options(error =recover) # c brings you back to the beginning
  • debug() & debugonce()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment