Recall & Review
beginner
What is the purpose of the
browser() function in R?The
browser() function pauses the execution of R code and allows you to inspect variables and step through the code interactively to find bugs.Click to reveal answer
beginner
How does
traceback() help in debugging R code?traceback() shows the sequence of function calls that led to an error, helping you understand where the problem happened.Click to reveal answer
intermediate
What is the use of
debug() in R?debug() marks a function so that when it is called, R enters the browser mode inside that function, allowing step-by-step execution.Click to reveal answer
intermediate
Explain the difference between
browser() and debug().browser() is placed manually inside code to pause execution at that point, while debug() is used to mark a function so that every time it runs, it pauses at the start.Click to reveal answer
advanced
What does the
recover() function do in R debugging?recover() allows you to choose which environment to enter after an error occurs, letting you inspect the state of the program at different call levels.Click to reveal answer
Which R function shows the call stack after an error?
✗ Incorrect
traceback() prints the sequence of calls that led to an error, helping locate the problem.
What happens when you use
debug() on a function?✗ Incorrect
debug() causes R to pause inside the function so you can step through the code.
Which debugging tool lets you interactively inspect variables at any point in your code?
✗ Incorrect
browser() pauses execution and lets you check variables and run commands interactively.
How does
recover() improve error handling?✗ Incorrect
recover() allows you to select the call frame to debug after an error happens.
When would you use
browser() instead of debug()?✗ Incorrect
browser() is placed at a specific spot in code to pause there, unlike debug() which pauses at function start.
Describe how you would use
debug() and browser() to find a bug in an R function.Think about when you want to pause the whole function vs a specific spot.
You got /4 concepts.
Explain the role of
traceback() and recover() in understanding errors in R.One shows the path, the other lets you explore the problem.
You got /3 concepts.