r - Selective suppressWarnings() that filters by regular expression -


in attempt generate code runs without warnings , hence can run options(warn=2), looking implementation of suppresswarnings routine filter warnings match given (vector of) regular expressions. warnings beyond control, famous

unrecognized record type 7, subtype 18 encountered in system file 

when reading spss files, , want selectively suppress these without affecting possible other warnings.

is there implementation of functionality?

suppress warnings withcallinghandlers , invokerestart, using "mufflewarning" restart mentioned on ?warning

withcallinghandlers({     x <- 0     warning("unrecognized record 123")     x <- x + 1     warning("another warning")     x + 1 }, warning = function(w) {     if (startswith(conditionmessage(w), "unrecognized record"))         invokerestart("mufflewarning") }) 

this has output

[1] 2 warning message: in withcallinghandlers({ : warning 

(use trycatch if instead stop on warning). @benbolker mentions doesn't handle translations; making more elaborate regex isn't going satisfactory. catching one's own warnings, 1 make , throw subclass of warning.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -