Re: [Rd] Capturing warnings with capture.output

2006-09-05 Thread Luke Tierney
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 > > > > >>

Re: [Rd] Capturing warnings with capture.output

2006-09-05 Thread Gabor Grothendieck
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

Re: [Rd] Capturing warnings with capture.output

2006-09-05 Thread hadley wickham
> 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.") >

Re: [Rd] Capturing warnings with capture.output

2006-08-29 Thread Gabor Grothendieck
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

[Rd] Capturing warnings with capture.output

2006-08-29 Thread hadley wickham
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