When options("warn") is 0, the default, the warning is not
printed until capture.output is done. Use warn=1 to capture
the warnings as messages:
> options(warn=0)
> txt0 <- capture.output({message("A message"); warning("A warning")},
> type="message")
Warning message:
In eval(expr, envir, enclos
>From the Details section of ?capture.output:
Messages sent to stderr() (including those from message, warning and stop)
are captured by type = "message". Note that this can be "unsafe" and should
only be used with care.
Capturing messages works as expected:
capture.output(message("!!!"), type =