title: How to resolve exception "eval failed, request status: error code: 127" in R and Java?
body: <p>I am using R and Java for displaying prediction.</p>
  
  <p>I have data of 5 hours. I want to predict 5th-hour data from four hours' data (memory with respect to date).
  By using 4 hours' data I am creating new collection and inserting the 5th hour's predicted data in a new collection. But I am getting the following error:</p>
  
  <pre><code>The Exception is eval failed, request status: error code: 127
  org.rosuda.REngine.Rserve.RserveException: eval failed, request status: error code: 127
  at org.rosuda.REngine.Rserve.RConnection.eval(RConnection.java:233)
  at scheduler.scheduler.predictions.getPredictionsofData(predictions.java:45)
  at pack.GetCollectionMultithreaded.getPredictionAndInsert(GetCollectionMultithreaded.java:386)
  at pack.GetCollectionMultithreaded.runCustomerListAndPredictionEvery5Min(GetCollectionMultithreaded.java:155)
  at pack.GetCollectionMultithreaded.main(GetCollectionMultithreaded.java:103)
  </code></pre>
  
  <p>Here is code:</p>
  
  <pre><code>public class predictions {
  
  public void getPredictionsofData(DB dbObj){
   FileInputStream fis = null;
  
   DBCollection network_device_realtime = dbObj.getCollection("mycollectionname");
  DBObject return_dobject = null;
  
  // For Network device1 realtime
  try{
   List&lt;String&gt; listOfIps = network_device_realtime.distinct("hostId");
   RConnection c = new RConnection(Rhost,Rport);
   c.eval("library(RMongo)");
   c.eval("library(plyr)");
   c.eval("library(randomForest)");
   c.eval(" db &lt;- mongoDbConnect('demo','localhost',27017)");
   for( int i= 0 ;i&lt;listOfIps.size(); i++){
       float my_predicted_date = 0 ;
               BasicDBObject criteria = new BasicDBObject();
       BasicDBObject projections = new BasicDBObject();
       criteria.put("hostId",listOfIps.get(i));
      projections.put("runtimeMillis", 1);
      DBCursor cursor = network_device_realtime.find(criteria,projections).sort(new BasicDBObject("runtimeMillis",-1)).limit(1);
      while(cursor.hasNext()) {   
          BasicDBObject obj = (BasicDBObject) cursor.next();
          my_predicted_date = (float) obj.getDouble("runtimeMillis");
      }
      // Set predict date for testing purpose 
       my_predicted_date = my_predicted_date-(4*60*60*1000);
  
      // for calculating predictions next 24 hrs
      for(int j = 1; j &lt;= 12 ;j++){
              my_predicted_date = my_predicted_date+(300*1000);//j*60*60*1000calculating next hrs data
          System.out.println("Date Gen in network: " +my_predicted_date);
  
           c.eval("query &lt;- dbGetQuery(db,'"+network_device_realtime+"','{\"hostId\":\""+listOfIps.get(i)+"\",\"cpuUtilization\":{\"$ne\":\"null\"},\"memoryUtilization\":{\"$ne\":\"NaN\"},\"runtimeMillis\":{\"$ne\":\"null\"}}')");
  
           c.eval("date &lt;- query$runtimeMillis");
      c.eval("host_id &lt;- query$hostId");
           c.eval("cpu &lt;-  query$cpuUtilization ");
      c.eval("memory &lt;- query$memoryutil");
           c.eval("all_data&lt;-data.frame(cpu,date)");
           c.eval("training&lt;- all_data");
  
           c.eval("rf_fit&lt;-randomForest(memory~date,data=training)");
           c.eval("df &lt;- data.frame(date="+my_predicted_date+ ")");
           c.eval("predictions&lt;-predict(rf_fit,newdata=new)");
           REXP memory_predictions= c.eval("predictions");
           c.eval("rf_fit&lt;-randomForest(cpu~date,data=training)");
           c.eval("df &lt;- data.frame(date="+my_predicted_date+ ")");
           c.eval("predictions&lt;-predict(rf_fit,newdata=new)");
           REXP cpu_predictions= c.eval("predictions");
           String json = ""; 
           json ="{\"memoryUtilization\":"+ memory_predictions + ",\"cpuUtilization\" : "+ cpu_predictions + ",\"hostId\" : \""+ listOfIps.get(i) + "\",\"runtimeMillis\":"+my_predicted_date+",\"deviceType\":\"snmp\"}";
           return_dobject=(DBObject) JSON.parse(json);
           dbObj.getCollection("prediction").insert(return_dobject);
          }
       }
           c.close();
      }
  catch(Exception e){
       System.out.println("ERROR: In Connection to R ");
       System.out.println("The Exception is "+ e.getMessage());
       e.printStackTrace();
   }
  }
  }//class
  </code></pre>
  
  <p>In this code I am getting error on this line:</p>
  
  <pre><code> c.eval("rf_fit&lt;-randomForest(memory~date,data=training)");
  </code></pre>
  
  <p>How do I resolve this error?</p>