R: how to clear all warnings R: how to clear all warnings r r

R: how to clear all warnings


Try assign("last.warning", NULL, envir = baseenv())


Take a look at suppressWarnings() to stop the warnings from showing up.

Notice in the help page for warnings that it says:

"....It is undocumented where last.warning is stored nor that it is visible, and this is subject to change. Prior to R 2.4.0 it was stored in the workspace, but no longer...."


I agree, I want to use a try() and gather up just the warnings generated by that try().

My solution for now is

assign("last.warning", NULL, envir = baseenv())    myFit  <- try(...)    warned <- warnings()assign("last.warning", NULL, envir = baseenv())