/** convenience method corresponding to <code>asDoubles()[0]</code> @return first entry returned by {@link #asDoubles} */ public double asDouble() throws REXPMismatchException { double[] d = asDoubles(); return d[0]; } /** convenience method corresponding to <code>asStrings()[0]</code>
/** convenience method corresponding to <code>asDoubles()[0]</code> @return first entry returned by {@link #asDoubles} */ public double asDouble() throws REXPMismatchException { double[] d = asDoubles(); return d[0]; } /** convenience method corresponding to <code>asStrings()[0]</code>
public double[] asDoubles() throws REXPMismatchException { return resolve().asDoubles(); } public RList asList() throws REXPMismatchException { return resolve().asList(); }
public double[] asDoubles() throws REXPMismatchException { return resolve().asDoubles(); } public RList asList() throws REXPMismatchException { return resolve().asList(); }
/** returns the content of the REXP as a matrix of doubles (2D-array: m[rows][cols]). This is the same form as used by popular math packages for Java, such as JAMA. This means that following leads to desired results:<br> <code>Matrix m=new Matrix(c.eval("matrix(c(1,2,3,4,5,6),2,3)").asDoubleMatrix());</code><br> @return 2D array of doubles in the form double[rows][cols] or <code>null</code> if the contents is no 2-dimensional matrix of doubles */ public double[][] asDoubleMatrix() throws REXPMismatchException { double[] ct = asDoubles(); REXP dim = getAttribute("dim"); if (dim == null) throw new REXPMismatchException(this, "matrix (dim attribute missing)"); int[] ds = dim.asIntegers(); if (ds.length != 2) throw new REXPMismatchException(this, "matrix (wrong dimensionality)"); int m = ds[0], n = ds[1]; double[][] r = new double[m][n]; // R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4) // we need to copy everything, since we create 2d array from 1d array int k = 0; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) r[j][i] = ct[k++]; return r; }
/** returns the content of the REXP as a matrix of doubles (2D-array: m[rows][cols]). This is the same form as used by popular math packages for Java, such as JAMA. This means that following leads to desired results:<br> <code>Matrix m=new Matrix(c.eval("matrix(c(1,2,3,4,5,6),2,3)").asDoubleMatrix());</code> @return 2D array of doubles in the form double[rows][cols] or <code>null</code> if the contents is no 2-dimensional matrix of doubles */ public double[][] asDoubleMatrix() throws REXPMismatchException { double[] ct = asDoubles(); REXP dim = getAttribute("dim"); if (dim==null) throw new REXPMismatchException(this, "matrix (dim attribute missing)"); int[] ds = dim.asIntegers(); if (ds.length!=2) throw new REXPMismatchException(this, "matrix (wrong dimensionality)"); int m = ds[0], n = ds[1]; double[][] r=new double[m][n]; // R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4) // we need to copy everything, since we create 2d array from 1d array int i=0,k=0; while (i<n) { int j=0; while (j<m) { r[j++][i]=ct[k++]; } i++; } return r; }
double[] b1 = xp.asDoubles(); outputData[n] = b1[b1.length - 1];
for (double d : rExp.asDoubles()) { boolResult.add (d > 0.00001 ? stringTrue : stringFalse); return new Double(rExp.asDoubles()[0]); for (double d : rExp.asDoubles()) { doubleResult.add(new Double(d)); return new Integer((int) rExp.asDoubles()[0]); for (double d : rExp.asDoubles()) { integerResult.add(new Integer((int) d)); return (Arrays.toString(rExp.asDoubles())); for (double d : rExp.asDoubles()) { stringResult.add(Double.toString(d));
double[] doubleArray = rexp.asDoubles(); result = doubleArray;
double da[]=cont.asDoubles(); int i=0, io=off; while(i<da.length) {
double da[]=cont.asDoubles(); int i=0, io=off; while(i<da.length) {
Double[] dAList = new Double[len]; for (int i = 0; i < len; i++) { dAList[i] = (retVal.asDoubles()[i]);
Double[] dAList = new Double[len]; for (int i = 0; i < len; i++) { dAList[i] = (retVal.asDoubles()[i]);