Debugging

Types of Bugs

  1. Define syntax and semantic errors.
  2. Compare and contrast syntax errors and semantic errors.
  3. Give examples of syntax errors and semantic errors in R.
  4. Given a bug in R code, identify whether it is a syntax error or a semantic error.

The Process of Debugging

  1. State the 4 main stages involved in debugging.
  2. Describe the sort of actions that can be taken during the stages of debugging.

traceback()

  1. Explain what traceback() does when run after encountering an error message.
  2. Given an error message and a call to traceback(), state the chain of functions that were called leading to the error.
  3. Use traceback() to help identify the bug leading to an error message.

Debugging Tools in R

  1. Use browser() to inspect the state of variables in a function.
  2. Use browser() to step through a function and into other functions.
  3. State the 5 main commands that are used after a call to browser() to step through code.
  4. Use browser() within RStudio, including the Environment and Traceback panes, to identify, characterize, and fix a bug in R code.