Currently I write:
warn = getOption("warn")
options(warn=-1)
foo()
options(warn=warn)
Is there a better solution?
suppressWarnings evaluates its expression in a context that ignores all warnings.
suppressPackageStartupMessages() method in R language can be used to disable messages displayed upon loading a package in R. This method is used to suppress package startup messages. The package should be pre-installed in R, otherwise, a warning is displayed upon function call.
Use suppressWarnings()
:
suppressWarnings(foo())
You wrap an expression in suppressWarnings()
(yet here foo()
returns an error, not a warning).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With