[BioC] error handling in R

James MacDonald jmacdon at med.umich.edu
Mon May 10 21:22:15 CEST 2004


You might look at either ?try or ?tryCatch.

An untested modification:

my.function(x){
	options(show.error.messages = FALSE)
	atmpt <- try(function.someone.else(x))
	options(show.error.messages = TRUE)
		if(inherits(atmpt, "try-error")){
		atmpt <- NA
	}
}

HTH,

Jim


James W. MacDonald
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

>>> "Kimpel, Mark W" <mkimpel at iupui.edu> 05/10/04 03:11PM >>>
A function I am calling from within one of my functions occasionally
returns an error (bug in the other function, not my fault). When this
happens, I would like for the value of the function that is blowing up
to be "NA". Instead, my whole function blows up. 

Is there a way I can do something like this?

my.function(x)
{
if (is.error(function.someone.else(x))) {NA} else
{function.someone.else(x)}
}

Unfortunately, R doesn't seem to provide for this "is.error" approach.
Is there another answer?

Thanks,

Mark

_______________________________________________
Bioconductor mailing list
Bioconductor at stat.math.ethz.ch 
https://www.stat.math.ethz.ch/mailman/listinfo/bioconductor



More information about the Bioconductor mailing list