tmessage | R Documentation |
message, warning or stop with a call trace prepended
tmessage(..., skip = 0)
twarning(..., skip = 0, call. = FALSE, noBreaks. = TRUE)
tstop(..., skip = 0, call. = FALSE)
... |
Passed to message, warning or stop |
skip |
Number of tracing levels to exclude. Default: 0 |
call. |
include twarning/tstop call? DEFAULT: FALSE (unlike the originals) |
noBreaks. |
reduce line breaks if |
NULL, as per message, warning or stop
traceCall for the generation of the trace
lower <- function(a, s) {tmessage("some stuff with ", a+10, skip=s); a}
upper <- function(b, skip=0) lower(b+5, skip)
upper(3) # upper -> lower: some stuff with 18
upper(3, skip=1) # no "lower" in trace
upper(3, skip=-1) # upper -> lower -> tmessage: some stuff with 18
tmessage("Some message", " to be displayed")
lower <- function(a, s) {twarning("some stuff with ", a+10, skip=s); a}
upper(7)
oop <- options(warn=1)
upper(7) # Warning: upper -> lower: some [] no line break :)
options(oop) ; rm(oop)
lower <- function(a, s) {tstop("some stuff with ", a+10, skip=s); a}
try( upper(7) ) # Error : try -> upper -> lower: some stuff with 22
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.