当前位置: 首页>>代码示例>>Java>>正文


Java REXP.asIntegers方法代码示例

本文整理汇总了Java中org.rosuda.REngine.REXP.asIntegers方法的典型用法代码示例。如果您正苦于以下问题:Java REXP.asIntegers方法的具体用法?Java REXP.asIntegers怎么用?Java REXP.asIntegers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.rosuda.REngine.REXP的用法示例。


在下文中一共展示了REXP.asIntegers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: asStringMatrix

import org.rosuda.REngine.REXP; //导入方法依赖的package包/类
private String[][] asStringMatrix(final REXP rexp) throws REXPMismatchException {
    final String[] ct = rexp.asStrings();
    final REXP dim = rexp.getAttribute("dim");
    if (dim == null) {
        throw new REXPMismatchException(rexp, "matrix (dim attribute missing)");
    }
    final int[] ds = dim.asIntegers();
    if (ds.length != 2) {
        throw new REXPMismatchException(rexp, "matrix (wrong dimensionality)");
    }
    final int m = ds[0], n = ds[1];

    final String[][] r = new String[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;
}
 
开发者ID:subes,项目名称:invesdwin-context-r,代码行数:24,代码来源:RserveScriptTaskResultsR.java

示例2: asIntegerMatrix

import org.rosuda.REngine.REXP; //导入方法依赖的package包/类
private int[][] asIntegerMatrix(final REXP rexp) throws REXPMismatchException {
    final int[] ct = rexp.asIntegers();
    final REXP dim = rexp.getAttribute("dim");
    if (dim == null) {
        throw new REXPMismatchException(rexp, "matrix (dim attribute missing)");
    }
    final int[] ds = dim.asIntegers();
    if (ds.length != 2) {
        throw new REXPMismatchException(rexp, "matrix (wrong dimensionality)");
    }
    final int m = ds[0], n = ds[1];

    final int[][] r = new int[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;
}
 
开发者ID:subes,项目名称:invesdwin-context-r,代码行数:24,代码来源:RserveScriptTaskResultsR.java

示例3: getBooleanVector

import org.rosuda.REngine.REXP; //导入方法依赖的package包/类
@Override
public boolean[] getBooleanVector(final String variable) {
    try {
        final REXP rexp = engine.unwrap().eval(variable);
        if (allIsNa(rexp)) {
            return null;
        } else {
            final int[] ints = rexp.asIntegers();
            final boolean[] booleanVector = new boolean[ints.length];
            for (int i = 0; i < ints.length; i++) {
                booleanVector[i] = ints[i] > 0;
            }
            return booleanVector;
        }
    } catch (final REXPMismatchException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-r,代码行数:19,代码来源:RserveScriptTaskResultsR.java

示例4: getIntegerVector

import org.rosuda.REngine.REXP; //导入方法依赖的package包/类
@Override
public int[] getIntegerVector(final String variable) {
    try {
        final REXP rexp = engine.unwrap().eval(variable);
        if (allIsNa(rexp)) {
            return null;
        } else {
            return rexp.asIntegers();
        }
    } catch (final REXPMismatchException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-r,代码行数:14,代码来源:RserveScriptTaskResultsR.java


注:本文中的org.rosuda.REngine.REXP.asIntegers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。