Error messages do not contain the problematic R commands

If the script that is run by an RScript operator generates an error, error messages are returned to the operator. Details about the command that caused the error are not returned.
The error message describes the error, but not the problematic R command. For example, if you have a script that is called bad.r that references a uninitialized object, you might get the following error information:
Error in eval.with.vis(expr, envir, enclos) : object 'Num1' not found

The RScript operator runs R scripts by using the command source("filename"). By default the source command does not return details about the command that failed.

There are two methods that you use to get more information about the statement that caused the error:
  • Specify the –verbose option in the rCommand parameter in the RScript operator. R code uses this option to control the printing of diagnostic messages.
    You can also use this option to debug your problematic bad.r script in the R environment as follows:
    /usr/bin/R –verbose –no-save
    > source("bad.r")
    'envir' chosen: <environment: R_GlobalEnv>
    ...
    --> parsed 1 expressions; now eval(.)ing them:  
    >>>> eval(expression_nr. 1 )                 
    =================
    > Num = Num1
    Error in eval.with.vis(expr, envir, enclos) : object 'Num1' not found
     >R_ReplConsole(): before "for(;;)" {main.c}
    
  • Wrap your script in a script that calls it with the echo=TRUE argument. If you specify this argument, the R program prints each expression.
    For example, the script s2.r contains the following statement:
    source("bad.r", echo=TRUE)
    If you run the s2.r script, all the lines from the bad.r script are output, as follows:
    > source("s2.r")
    > Num = Num1
    Error in eval.with.vis(expr, envir, enclos) : object 'Num1' not found 
Note: When you use either of these methods to generate more messages, there is a performance impact for your application.

After you identify the problematic statement, you can fix it and optionally disable any debugging options that are no longer required.