traceCall | R Documentation |
trace the call stack e.g. for error checking and format output for do.call levels
traceCall(
skip = 0,
prefix = "\nCall stack: ",
suffix = "\n",
vigremove = TRUE,
shiremove = TRUE,
mesremove = TRUE
)
skip |
Number of levels to skip in |
prefix |
Prefix prepended to the output character string. DEFAULT: "\nCall stack: " |
suffix |
Suffix appended to the end of the output. DEFAULT: "\n" |
vigremove |
Logical: remove call created using devtools::build_vignettes()? DEFAULT: TRUE |
shiremove |
Logical: remove shiny::runApp ... renderPlot? DEFAULT: TRUE |
mesremove |
Logical: remove call part from |
Character string with the call stack
Berry Boessenkool, berry-b@gmx.de, Sep 2016 + March 2017
tmessage
, tryStack
, checkFile
for example usage
lower <- function(a, s) {warning(traceCall(s, mesremove=FALSE), "stupid berry warning: ", a+10); a}
upper <- function(b, skip=0) lower(b+5, skip)
upper(3)
# Since 2022-05-04, use tmessage / twarning / tstop instead!
upper(3, skip=1) # traceCall skips last level (R3: warning, R4.1: .makeMessage, R4.2: lapply)
upper(3, skip=6) # now the stack is empty
d <- tryStack(upper("four"), silent=TRUE)
inherits(d, "try-error")
cat(d)
lower <- function(a,...) {warning(traceCall(1, prefix="in ", suffix=": "),
"How to use traceCall in functions ", call.=FALSE); a}
upper(3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.