traceback
Print Call Stack After Error

Description

Prints the calls in the process of evaluation at the time of an error, or prints any list of deparsed calls.

Usage

traceback(x = NULL, max.lines = getOption("deparse.max.lines"), 
          print.context = TRUE)

Arguments

x any list of calls. If NULL (the default), then the saved call stack from the most recent error is used. A numeric x is treated the same as NULL.
max.lines the maximum number of lines to be printed for each call. If this is NULL or any other non-numeric value, a maximum of 10 lines are printed.
print.context a logical flag. If TRUE (the default) and the engine has saved additional context information with the call stack, it is printed to the screen instead of the x value or the normal saved call stack. Context information is available only when starting the engine with the -debug flag. Set this argument to FALSE to ignore any context information.

Details

Use traceback when an error occurs that you do not understand. traceback reports the function that created the error and the calling sequence that led to the function call. If this information is not sufficient to discover the cause of the error, then use debugger, browser, or trace.
When you use browser, also using traceback() can help you determine how browser was called. This is particularly true when browser is invoked as a result of an interrupt or tracing action.
Two techniques useful for preventing errors during loops, or for preventing other long calculations from losing all intermediate results are:
Differences between Spotfire Enterprise Runtime for R and Open-source R
If the max.lines argument is NULL or any other non-numeric value, open-source R prints all of the lines, whereas Spotfire Enterprise Runtime for R prints only a maximum of 10 lines.
The print.context argument is in Spotfire Enterprise Runtime for R only; it is not in open-source R.
See Also
assign, debugger, browser, trace, try, options.
Examples
f1 <- function(x) { y <- x+4; f2(y)}
f2 <- function(x) undefined.variable + x
f1(5)
traceback()

x <- c(2.36, 0.89, -0.25, -0.86, 0.58) y <- c(0.67, 0.094, 0.49, 0.46, 0.37) traceback(x) # print x list of deparsed calls glm(y~x, family = quasi(link = power(2))) # generate an error traceback() # print the call stack with error information traceback(max.lines = 3) # print the call stack with error information, # the lines for each call is no more than 3.

Package base version 6.1.1-7
Package Index