The Code is below:
RConnection connection = new RConnection();
String load_pkgs = "require(Rserve); require(forecast)";
connection.eval(load_pkgs);
String strx1 = "xData = read.table(\"D:\\\\R_TESTS\\\\ts_interval_data21.csv\",sep=\"|\",header=FALSE,col.names=c(\"a\",\"b\",\"c\",\"d\",\"xData\",\"f\"))[,\"xData\",drop=FALSE]";
connection.eval(strx1);
String strx2 = "x = xData[1:100,1]; fit = auto.arima(x);";
connection.eval(strx2);
String strx3 = "result = forecast(fit,h=12);";
connection.eval(strx3);
Object result = (Object)connection.eval("result").asNativeJavaObject();
HashMap map = (HashMap)result;
List<Object> objects = new ArrayList<Object>(map.keySet());
double values[] = (double[])objects.get(4);
for(int i=0;i<values.length;i++)
{
System.out.println((i+1)+":"+values[i]);
}
actually I'm running R inside the JAVA using Rserve() connection,now every thing works fine but when running the program the output will be totally wrong and while debugging the output is perfect. I'm not able to find the bug in my code please review the code and leave your suggestions. Thank You
I hope the following images will help:
1) Image depicts output in DEBUG mode

