[R] run R under linux

Jason Turner jasont at indigoindustrial.co.nz
Tue Oct 21 23:15:54 CEST 2003


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




More information about the R-help mailing list