I have a source file (in knitr) containing plots which use a particular font family. I\'d like to suppress the warning messages
In grid.Call(L_textBo
Use
withCallingHandlers({
<your code>
}, warning=function(w) {
if (<your warning>)
invokeRestart("muffleWarning")
})
For instance,
x = 1
withCallingHandlers({
warning("oops")
warning("my oops ", x)
x
}, warning=function(w) {
if (startsWith(conditionMessage(w), "my oops"))
invokeRestart("muffleWarning")
})
produces output
[1] 1
Warning message:
In withCallingHandlers({ : oops
>
The limitation is that the conditionMessage may be translated to another language (especially if from a base function) so that the text will not be reliably identified.
See Selective suppressWarnings() that filters by regular expression.