The debug()
method in R allows the user to debug a function, line by line, upon its execution.
The name of the function that needs to be debugged is the parameter in debug()
.
Right before the function call, the debug()
method is used. On the execution of the program, the debug()
method continues to print the values of the variables in the function, line by line. It can also produce graphs of the results of the code.
There are a few actions that can be done once the debug()
method, as listed below.
debug()
function continue till the end of the code sectionHere, the debug()
method calls the fun()
function defined by the user. It tests the execution on the assigned parameters of fun()
and runs the code each line at a time.
fun <- function(value1,value2){subval <- value2 - value1square <- subval^2get <- sum(square)get}set.seed(100)value2 <- rnorm(100)debug(fun)fun(1,value2)