Skip to content

try-error in batch and interactive mode

2 messages · Jun Yan, Uwe Ligges

#
I have a tiny R script performing two tasks, the first one of which may
contain error.

mammon(12)% cat z.R
version
options(show.error.messages = FALSE)
try(b <- log("foo"))  ## task 1
1 + 2                 ## task 2

Running in batch mode from a solaries machine, the second task never got
started; see below:

mammon(13)% R BATCH --vanilla -q z.R
mammon(14)% cat z.Rout
_                   
platform sparc-sun-solaris2.8
arch     sparc               
os       solaris2.8          
system   sparc, solaris2.8   
status                       
major    1                   
minor    5.1                 
year     2002                
month    06                  
day      17                  
language R
The second task does start if run on a linux machine.

ludwig(22)% cat z.Rout
_                
platform i686-pc-linux-gnu
arch     i686             
os       linux-gnu        
system   i686, linux-gnu  
status                    
major    1                
minor    5.1              
year     2002             
month    06               
day      17               
language R
[1] 3
[1] 0.87 0.07 0.90 0.00 0.00
The same code works well if pasted into an interactive R window.

I wonder what is causing the problem on solaries. I need to run a program
on solaries because the program calls an executable only available for
solaries.

Thanks,

Jun

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Jun Yan wrote:
It's not easy to test that, is it?
The next expressions will be evaluated anyway -- with or without a
working try() around it.
For me it looks like a bug. 
I am not very sure, particularly since it is there since at least
R-1.1.1, which is the oldest running R version I have got on our Solaris
system, and nobody reported anything like this (nothing similar in the
database). 


Regularly you would write a function such as 

  testit <- function(){
    version
    options(show.error.messages = FALSE)
    try(b <- log("foo"))  ## task 1
    1 + 2                 ## task 2
  }

  testit()

which works in a batch file and is at least a workaround.

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._