- 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.
- 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.
- If I still don't have enough information, I usually use the debug() function and step through the script line by line.
- traceback() # shows the stack at the time of the last error
- options(error =recover) # c brings you back to the beginning
- debug() & debugonce()