save warnings/errors from function without showing on screen
<p>I found this very helpful factory to convert any function into  a function that capture its values, errors, and warnings (<a href="https://stackoverflow.com/questions/4948361/how-do-i-save-warnings-and-errors-as-output-from-a-function/4952908#4952908">How do I save warnings and errors as output from a function?</a>):</p>

<pre><code>factory &lt;- function(fun)
function(...) {
    warn &lt;- err &lt;- NULL
    res &lt;- withCallingHandlers(
        tryCatch(fun(...), error=function(e) {
            err &lt;&lt;- conditionMessage(e)
            NULL
        }), warning=function(w) {
            warn &lt;&lt;- append(warn, conditionMessage(w))
            invokeRestart("muffleWarning")
        })
    list(res, warn=warn, err=err)
}
</code></pre>

<p>My problem is that errors/warnings are also shown on screen (on top of being captured by the factory). How can I change it so that errors/warnings do not show on screen?
Thanks</p>