/** * Sends a single command to R. * * @param sz The R command * @param szDescription The Description showing up before the output */ private String[] sendCommand2R(String sz) { // set command if (sz.length() == 0) { return null; } // parse long lParsed = re.rniParse(sz, 1); // eval long lEvaluated = re.rniEval(lParsed, 0); // generate REXP if (lEvaluated > 0) { REXP exp = new REXP(re, lEvaluated); String[] szArr = exp.asStringArray(); if (szArr != null) { return szArr; } double[] dArr = exp.asDoubleArray(); if (dArr != null) { String[] szDArr = new String[dArr.length]; for (int cnt = 0; cnt < dArr.length; ++cnt) { szDArr[cnt] = String.valueOf(dArr[cnt]); } return szDArr; } int[] iArr = exp.asIntArray(); if (iArr != null) { String[] szIArr = new String[iArr.length]; for (int cnt = 0; cnt < iArr.length; ++cnt) { szIArr[cnt] = String.valueOf(iArr[cnt]); } return szIArr; } } return null; }
@Override public int[] asIntegers() { return r.asIntArray(); }