Look at how suppressWarnings does this.
Best,
luke
On Tue, 5 Sep 2006, hadley wickham wrote:
>> Something like this which displays the warnings and also writes
>> them to out so that they are captured:
>
> Is it possible to not display the warnings (just write them out) ?
>
> Hadley
>
>
>
>
>>
Modify withWarnings in:
https://stat.ethz.ch/pipermail/r-help/2004-June/052132.html
like this:
withWarnings <- function(expr) {
wHandler <- function(w) {
cat(w$message, "\n")
invokeRestart("muffleWarning")
}
withCallingHandlers(expr, warning = wHandler)
}
# test
out
> Something like this which displays the warnings and also writes
> them to out so that they are captured:
Is it possible to not display the warnings (just write them out) ?
Hadley
>
> out <- capture.output(
>withCallingHandlers({
> print(1)
> warning("A warning.")
>
Something like this which displays the warnings and also writes
them to out so that they are captured:
out <- capture.output(
withCallingHandlers({
print(1)
warning("A warning.")
print(2)
warning("Another warning.")
print(3)
}, warning = function(x) ca
Is there any way to include warnings in the output from capture.output? eg:
a <- capture.output(warning("test"))
all.equal(a, "Warning message: \n test ")
Conceptually, this seems like redirecting stderr to stdout, or somehow
changing warning to simple print it's output. I've had a look at
tryC