[R] run R under linux

Zhen Pang nusbj at hotmail.com
Wed Oct 22 09:05:53 CEST 2003


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 <jasont at indigoindustrial.co.nz>
>To: Zhen Pang <nusbj at hotmail.com>
>CC: R-help at stat.math.ethz.ch
>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
>jasont at indigoindustrial.co.nz
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list