Message-ID: <4EFB6F73.5040409@science.oregonstate.edu>
Date: 2011-12-28T19:35:15Z
From: Paul Murtaugh
Subject: error options
Hi,
I'm running simulations that include a function that occasionally fails
because of an unpredictable singularity in a matrix that it tries to invert.
I'd like to have the function return 'NA' when that happens, so that the
simulations can continue. I've tried things like:
test <- function() {
options(error=return(NA))
x <- solve(0)
return(x)
}
which does return 'NA'. But it returns 'NA' whether or not there's an
error in the function:
test <- function() {
options(error=return(NA))
x <- 0
return(x)
}
test()
[1] NA
What am I missing here?
Thanks in advance
-Paul