本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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);
}
}