R/withConditions.R

Defines functions withConditions

Documented in withConditions

withConditions <- function(expr) { 	
	myWarnings <- NULL
	myErrors <- NULL 	
	wHandler <- function(w) {
		myWarnings <<- c(myWarnings, w$message) 	 
		invokeRestart("muffleWarning") 	
	}
	val <- withCallingHandlers(expr, warning = wHandler)
	if (!is.null(myWarnings)) {
		myWarnings = unique(myWarnings)
		warns = paste("<div>",myWarnings,"</div>",sep="", collapse="")
		warnMessages = paste("<p class = \"b\">Warning:</p>",warns,sep="")
		attr(val,"warnings") = warnMessages
		}
	return(val)
}

Try the DeducerRichOutput package in your browser

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

DeducerRichOutput documentation built on May 2, 2019, 4:53 p.m.