Wednesday, April 27, 2022

[FIXED] How to suppress warnings globally in an R Script

Issue

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?


Solution

You could use

options(warn=-1)

But note that turning off warning messages globally might not be a good idea.

To turn warnings back on, use

options(warn=0)

(or whatever your default is for warn, see this answer)



Answered By - sieste
Answer Checked By - Terry (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.