org.rosuda.REngine.REXPString Java Examples
The following examples show how to use
org.rosuda.REngine.REXPString.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RBridgeControl.java From kieker with Apache License 2.0 | 6 votes |
/** * Wraps the execution of an arbitrary R expression. Both errors and results are logged. * * @param input * The R expression to evaluate. * * @return The result or the error of the evaluation of the given R expression. The method tries to convert it into a string, if possible. */ public Object evalWithR(final String input) throws InvalidREvaluationResultException { Object out = null; try { out = this.rCon.eval(input); Object output = null; if (out instanceof REXPString) { output = ((REXPString) out).asString(); } else if (out instanceof REXPLogical) { output = ((REXPLogical) out).toDebugString(); } else if (out != null) { output = out; } else { throw new InvalidREvaluationResultException("Got a null result for evaluation input: \"" + input + "\""); } RBridgeControl.LOGGER.trace("> REXP: {} return: {}", input, output); } catch (final REXPMismatchException exc) { RBridgeControl.LOGGER.error("Error R expr.: {} Cause: {}", input, exc.getMessage(), exc); } return out; }
Example #2
Source File: Rsession.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
public static REXPList asRList(Map<?, ?> m) { RList l = new RList(); for (Object o : m.keySet()) { Object v = m.get(o); if (v instanceof Double) { l.put(o.toString(), new REXPDouble((Double) v)); } else if (v instanceof double[]) { l.put(o.toString(), new REXPDouble((double[]) v)); } else if (v instanceof Integer) { l.put(o.toString(), new REXPInteger((Integer) v)); } else if (v instanceof int[]) { l.put(o.toString(), new REXPInteger((int[]) v)); } else if (v instanceof String) { l.put(o.toString(), new REXPString((String) v)); } else if (v instanceof String[]) { l.put(o.toString(), new REXPString((String[]) v)); } else if (v instanceof Boolean) { l.put(o.toString(), new REXPLogical((Boolean) v)); } else if (v instanceof boolean[]) { l.put(o.toString(), new REXPLogical((boolean[]) v)); } else if (v instanceof Map) { l.put(o.toString(), asRList((Map<?, ?>) v)); } else if (v instanceof RList) { l.put(o.toString(), (RList) v); } else if (v == null) { l.put(o.toString(), new REXPNull()); } else { System.err.println("Could not cast object " + o + " : " + v); } } return new REXPList(l); }
Example #3
Source File: Rsession.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
public static REXPList asRList(Map<?, ?> m) { RList l = new RList(); for (Object o : m.keySet()) { Object v = m.get(o); if (v instanceof Double) { l.put(o.toString(), new REXPDouble((Double) v)); } else if (v instanceof double[]) { l.put(o.toString(), new REXPDouble((double[]) v)); } else if (v instanceof Integer) { l.put(o.toString(), new REXPInteger((Integer) v)); } else if (v instanceof int[]) { l.put(o.toString(), new REXPInteger((int[]) v)); } else if (v instanceof String) { l.put(o.toString(), new REXPString((String) v)); } else if (v instanceof String[]) { l.put(o.toString(), new REXPString((String[]) v)); } else if (v instanceof Boolean) { l.put(o.toString(), new REXPLogical((Boolean) v)); } else if (v instanceof boolean[]) { l.put(o.toString(), new REXPLogical((boolean[]) v)); } else if (v instanceof Map) { l.put(o.toString(), asRList((Map<?, ?>) v)); } else if (v instanceof RList) { l.put(o.toString(), (RList) v); } else if (v == null) { l.put(o.toString(), new REXPNull()); } else { System.err.println("Could not cast object " + o + " : " + v); } } return new REXPList(l); }
Example #4
Source File: RBridgeControl.java From kieker with Apache License 2.0 | 5 votes |
/** * * @param input * inputstring * @return Rdata */ public String eString(final String input) { final String resultOnFailure = ""; try { final Object evaluationResult = this.evalWithR(input); final REXPString stringResult = (REXPString) evaluationResult; return stringResult.toString(); } catch (final InvalidREvaluationResultException exc) { RBridgeControl.LOGGER.error(exc.getMessage(), exc); return resultOnFailure; } }