public REXP engineEval(String expression, boolean resolve) {
   history.add(expression);
   try {
     rs.parseAndEval(ERROR_VAR + " <<- NULL", env, true);
     // String expression2 = expression.replace("\"", "\\\"");
     // String s1 = "parse(text=\"" + expression2 + "\")";
     // System.out.println(s1);
     /*REXP rexp = rs.parseAndEval(expression);
     REXP errRexp = rs.parseAndEval(ERROR_VAR);
     if (!(errRexp instanceof REXPNull)) {
         String error = errRexp.asString();
         throw new RErrorException(error);
     }*/
     REXP res = rs.parseAndEval(expression, env, resolve);
     REXP errRexp = rs.parseAndEval(ERROR_VAR, env, true);
     if (!(errRexp instanceof REXPNull)) {
       String error = errRexp.asString();
       throw new RErrorException(error);
     }
     return res;
   } catch (org.rosuda.REngine.REngineException e) {
     throw new RuntimeException(e);
   } catch (REXPMismatchException e) {
     // should not happen
     throw new RuntimeException(e);
   }
 }
 @Override
 public String[] getWarning() {
   String[] warning;
   try {
     // dont know what happens here, check this. if i dont call this twice i get null.
     rs.parseAndEval("last.warning");
     warning = rs.parseAndEval("last.warning").asList().keys();
   } catch (Exception e) {
     throw new REngineException(e);
   }
   if (warning.length > 0 && !warning[0].equals("NO_WARNING")) return warning;
   return null;
 }
 public void put(String varName, Object obj) throws REngineException {
   history.add("# Assigning " + obj.toString() + " to " + varName);
   try {
     if (obj instanceof RObjectREngine) {
       rs.assign(varName, ((RObjectREngine) obj).getWrapped());
     }
   } catch (Exception e) {
     throw new REngineException(e);
   }
 }
 public RCallServicesREngine(REngine rs, String envir) {
   this.rs = rs;
   try {
     env = rs.parseAndEval(envir);
   } catch (org.rosuda.REngine.REngineException e) {
     e.printStackTrace(); // To change body of catch statement use File | Settings | File
     // Templates.
   } catch (REXPMismatchException e) {
     e.printStackTrace(); // To change body of catch statement use File | Settings | File
     // Templates.
   }
   try {
     rs.parseAndEval(
         "options(error = function() { assign(\"" + ERROR_VAR + "\", geterrmessage()})",
         env,
         true);
   } catch (org.rosuda.REngine.REngineException e) {
     throw new REngineException(e);
   } catch (REXPMismatchException e) {
     throw new REngineException(e);
   }
 }