R Programming question bank focuses on “Debugging Tools”
1. __________ prints out the function call stack after an error occurs.
a) trace()
b) traceback()
c) back()
d) traback()
Answer: b
Clarification: traceback() does nothing if there’s no error. trace() Interactive tracing and debugging of calls to a function or method.
2. Point out the wrong statement?
a) The primary task of debugging any R code is correctly diagnosing what the problem is
b) R provides only two tools to help you with debugging your code
c) print statement can be used for debugging purpose
d) The traceback() function must be called immediately after an error occurs
Answer: b
Clarification: R provides a number of tools to help you with debugging your code.
3. Which of the following is primary tool for debugging?
a) debug()
b) trace()
c) browser()
d) traceback()
Answer: a
Clarification: Primary tools are mainly used for debugging R code.
4. ________ allows you to insert debugging code into a function a specific places
a) debug()
b) trace()
c) browser()
d) traceback()
Answer: b
Clarification: The function call stack is the sequence of functions that was called before the error occurred.
5. Point out the correct statement?
a) The traceback() function must be called immediately after an error occurs
b) The debugger calls the browser at the very low level of the function body
c) Every time you call the mod() function it will launch the interactive debugger
d) R provides only two tools to help you with debugging your code
Answer: a
Clarification: Once another function is called, you lose the traceback.
6. _______ allows you to modify the error behavior so that you can browse the function call stack
a) debug()
b) trace()
c) recover()
d) traceback()
Answer: c
Clarification: The recover() function can be used to modify the error behavior of R when an error occurs.
7. ______ suspends the execution of a function wherever it is called and puts the function in debug mode.
a) debug()
b) trace()
c) recover()
d) browser()
Answer: d
Clarification: The debug() function initiates an interactive debugger (also known as the “browser” in R) for a function.
8. debug() flags a function for ______ mode in R mode.
a) debug
b) run
c) compile
d) recover
Answer: b
Clarification: debug() allows you to step through execution of a function one line at a time.