I have a long R script that throws some warnings, which I can ignore. I could use
suppressWarnings(expr)
for single statements. But how can I suppress warnings in R globally? Is there an option for this?
I have a long R script that throws some warnings, which I can ignore. I could use
suppressWarnings(expr)
for single statements. But how can I suppress warnings in R globally? Is there an option for this?
Have a look at
?options
and usewarn
:You could use
But note that turning off warning messages globally might not be a good idea.
To turn warnings back on, use
(or whatever your default is for
warn
, see this answer)You want
options(warn=-1)
. However, note thatwarn=0
is not the safest warning level and it should not be assumed as the current one, particularly within scripts or functions. Thus the safest way to temporary turn off warnings is:I have replaced the
printf
calls with calls towarning
in the C-code now. It will be effective in the version 2.17.2 which should be available tomorrow night. Then you should be able to avoid the warnings withsuppressWarnings()
or any of the other above mentioned methods.