/** convenience method equivalent to <code>assign(symbol, new REXPDouble(d), null)</code> (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, double[] d) throws REngineException { try { assign(symbol, new REXPDouble(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,double[]): "+e)); } } /** convenience method equivalent to <code>assign(symbol, new REXPInteger(d), null)</code> (see {@link #assign(String, REXP, REXP)})
/** * * @param input * string * @return {@link Double#NaN} in case of error, else dbvalue */ public double eDbl(final String input) { final double resultOnFailure = Double.NaN; try { final Object evaluationResult = this.evalWithR(input); final REXPDouble doubleResult = (REXPDouble) evaluationResult; return doubleResult.asDouble(); } catch (final REXPMismatchException exc) { RBridgeControl.LOGGER.error("Error casting value from R: {} Cause: {}", input, exc); return resultOnFailure; } catch (final InvalidREvaluationResultException exc) { RBridgeControl.LOGGER.error(exc.getMessage(), exc); return resultOnFailure; } }
/** returns a boolean vector of the same length as this vector with <code>true</code> for NA values and <code>false</code> for any other values (including NaNs) */ public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = isNA(payload[i]); i++; } return a; }
/** convenience method equivalent to <code>assign(symbol, new REXPDouble(d), null)</code> (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, double[] d) throws REngineException { try { assign(symbol, new REXPDouble(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,double[]): "+e)); } } /** convenience method equivalent to <code>assign(symbol, new REXPInteger(d), null)</code> (see {@link #assign(String, REXP, REXP)})
/** returns a boolean vector of the same length as this vector with <code>true</code> for NA values and <code>false</code> for any other values (including NaNs) */ public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = isNA(payload[i]); i++; } return a; }
/** * * @param input * string * @return {@link Double#NaN} in case of error, else dbvalue */ public double eDbl(final String input) { final double resultOnFailure = Double.NaN; try { final Object evaluationResult = this.evalWithR(input); final REXPDouble doubleResult = (REXPDouble) evaluationResult; return doubleResult.asDouble(); } catch (final REXPMismatchException exc) { RBridgeControl.LOG.error("Error casting value from R: " + input + " Cause: " + exc); return resultOnFailure; } catch (final InvalidREvaluationResultException exc) { RBridgeControl.LOG.error(exc.getMessage(), exc); return resultOnFailure; } }
return new REXPDouble((Double) value ); case INTEGER: return new REXPInteger((Integer) value); doubles[i] = (Double) values.get(i); return new REXPDouble(doubles);
return new REXPDouble( ((Float)o).doubleValue() ) ; return new REXPDouble( ((Double)o).doubleValue() ) ; doubles[i] = (double)floats[i] ; return new REXPDouble( doubles ); doubles[i] = floats[i].doubleValue() ; return new REXPDouble( doubles ); return new REXPDouble( (double[])o ) ; d[i] = doubles[i].doubleValue() ; return new REXPDouble( d );
return new REXPDouble( ((Float)o).doubleValue() ) ; return new REXPDouble( ((Double)o).doubleValue() ) ; doubles[i] = (double)floats[i] ; return new REXPDouble( doubles ); doubles[i] = floats[i].doubleValue() ; return new REXPDouble( doubles ); return new REXPDouble( (double[])o ) ; d[i] = doubles[i].doubleValue() ; return new REXPDouble( d );
/** creates a REXP that represents a double matrix in R based on matrix of doubles (2D-array: m[rows][cols]). This is the same form as used by popular math packages for Java, such as JAMA. The result of this function can be used in {@link REngine.assign} to store a matrix in R. @param matrix array <code>double[rows][colums]</code> containing the matrix to convert into a REXP. If <code>matrix</code> is <code>null</code> or either of the dimensions is 0 then the resulting matrix will have the dimensions <code>0 x 0</code> (Note: Java cannot represent <code>0 x n</code> matrices for <code>n > 0</code>, so special matrices with one dimension of 0 can only be created by setting dimensions directly). @return <code>REXPDouble</code> with "dim" attribute which constitutes a matrix in R */ public static REXP createDoubleMatrix(double[][] matrix) { int m = 0, n = 0; double a[]; if (matrix != null && matrix.length != 0 && matrix[0].length != 0) { m = matrix.length; n = matrix[0].length; a = new double[m * n]; int k = 0; for (int j = 0; j < n; j++) for (int i = 0; i < m; i++) a[k++] = matrix[i][j]; } else a = new double[0]; return new REXPDouble(a, new REXPList( new RList( new REXP[] { new REXPInteger(new int[] { m, n }) }, new String[] { "dim" }) ) ); }
o=eox; cont = new REXPDouble(d, getAttr()); return o; o=eox; cont = new REXPDouble(d, getAttr()); return o;
o=eox; cont = new REXPDouble(d, getAttr()); return o; o=eox; cont = new REXPDouble(d, getAttr()); return o;
double[] dArr = new double[1]; dArr[0] = (Double) value; connectable.getRengine().assign(key, new REXPDouble(dArr)); break; case REXP_STR: break; case REXP_ARRAY_DOUBLE: connectable.getRengine().assign(key, new REXPDouble((double[]) value)); break; case REXP_ARRAY_STR:
double[] dArr = new double[1]; dArr[0] = (Double)value; connectable.getRengine().assign(key, new REXPDouble(dArr)); break; case REXP_STR: break; case REXP_ARRAY_DOUBLE: connectable.getRengine().assign(key, new REXPDouble((double[])value)); break; case REXP_ARRAY_STR: