Debugging
One way to debug is to enclose your code as a function with the R statements enclosed in brackets.
For example, one could package up ones code into a function named "mycode" by statements of the form.
mycode <- function() { R commands * * * }
From the console window, "source" this code to load it into the R environment, and then execute the statement
>debug(mycode)
When mycode()
is executed at the command prompt, normal program execution will be suspended, and
the program will progress line by line through the function. You can examine the local variables by typing their
names. To exit the debugger, type Q. See debug for details.
To toggle off the debug mode of a function use the command
>undebug(functionName);
":Sourcing" the function toggles off the debug mode.
See Also : Functions
Original Documentation : debug
UCLA Mathematics Department | ©2000 |