This project is read-only.

Handling error messages and warning in R.net

Dec 14, 2011 at 9:03 AM
Edited Dec 14, 2011 at 9:16 AM

Objective: To capture the warning thrown by the R script in R.NET

When I use the below script in R Console it gave me the output as  string "Warning"
jj = ts(scan("jj.dat"),  start=1960, frequency=4) 
tryCatch(arima(jj, order = c(1, 0,1)), warning=function(w) cat("Warning"))

I tried to use the same code in R.NET and expected to get the stirng "Warning", but I'm getting Parser Exception showing "Code error". Below is the code snippet which I tried in R.NET.
 

try
{

                string script = "tryCatch(arima(jj, order = c(4, 0,6)), warning=function(w) cat(\"Warning\"))";
                
                string str=engine.EagerEvaluate("script").AsCharacter().First();//*

}
catch (Exception ex)
{
                string s =ex.ToString();
}

Kindly help me on this trouble.

Jun 25, 2012 at 9:47 AM

Try this solution: http://rdotnet.codeplex.com/discussions/261917 (my two posts at the end of the thread).

Regards.