Thank you for your help. But try() seems to only allow for an expression. My simulation have serveral expressions which possibly have problem. Is there any possibility to include them all in the try()? If not, I seem to use several try().
From: Jason Turner <[EMAIL PROTECTED]> To: Zhen Pang <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: [R] run R under linux Date: Wed, 22 Oct 2003 10:15:54 +1300
Zhen Pang wrote:
We are not allowed to submit job directly, so I never type R to use R, just make a batch. How can I use try() to correct my codes? In the interactive mode, I know how to continue, but now I never enter the R window, where to find my results and save seed to continue?
Like you'd program any exception handling. A toy example to get you started might look like this:
(somewhere inside your script file) ... results <- vector(length=200,mode="numeric") #or whatever you use set.seed(123) ... errors <- list()
for(ii in 1:200) { foo <- try(some.simulation.thingy(your.params)) if(inherits(foo,"try-error")) { #something bombed results[ii] <- NA errors[[as.character(ii)]] <- foo } else { #it worked results[ii] <- foo } } ... save(results,errors,file="results+errors.RData") ... The end.
Play with that, and see if you get some useful ideas.
Cheers
Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz 64-21-343-545 [EMAIL PROTECTED]
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
