R/utilty.R

Defines functions hushWarning

Documented in hushWarning

##' Selectively muffle warnings based on output
##'
##' @param expr an expression
##' @param regexp a regexp to be matched (with str_detect)
##' @return the result of expr
##' @examples
##' CellaRepertorium:::hushWarning(warning('Beware the rabbit'), 'rabbit')
##' CellaRepertorium:::hushWarning(warning('Beware the rabbit'), 'hedgehog')
hushWarning <- function(expr, regexp){
    withCallingHandlers(expr, warning=function(w){
        if(grepl(regexp, conditionMessage(w))) invokeRestart("muffleWarning")
    })
}

Try the CellaRepertorium package in your browser

Any scripts or data that you put into this service are public.

CellaRepertorium documentation built on Nov. 8, 2020, 7:48 p.m.