Search in sources :

Example 1 with REXPList

use of org.rosuda.REngine.REXPList in project rsession by yannrichet.

the class RserveSession method cat.

// <editor-fold defaultstate="collapsed" desc="Conveniency static String methods">
public static String cat(RList list) {
    if (list == null || list.names == null) {
        return null;
    }
    try {
        StringBuffer sb = new StringBuffer("\t");
        double[][] data = new double[list.names.size()][];
        for (int i = 0; i < list.size(); i++) {
            String n = list.keyAt(i);
            sb.append(n + "\t");
            data[i] = list.at(n).asDoubles();
        }
        sb.append("\n");
        for (int i = 0; i < data[0].length; i++) {
            sb.append((i + 1) + "\t");
            for (int j = 0; j < data.length; j++) {
                sb.append(data[j][i] + "\t");
            }
            sb.append("\n");
        }
        return sb.toString();
    } catch (REXPMismatchException r) {
        return "(Not a numeric dataframe)\n" + new REXPList(list).toDebugString();
    }
}
Also used : REXPMismatchException(org.rosuda.REngine.REXPMismatchException) REXPString(org.rosuda.REngine.REXPString) REXPList(org.rosuda.REngine.REXPList)

Aggregations

REXPList (org.rosuda.REngine.REXPList)1 REXPMismatchException (org.rosuda.REngine.REXPMismatchException)1 REXPString (org.rosuda.REngine.REXPString)1