本文整理汇总了Java中org.rosuda.REngine.REXPLogical类的典型用法代码示例。如果您正苦于以下问题:Java REXPLogical类的具体用法?Java REXPLogical怎么用?Java REXPLogical使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
REXPLogical类属于org.rosuda.REngine包,在下文中一共展示了REXPLogical类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isTRUE
import org.rosuda.REngine.REXPLogical; //导入依赖的package包/类
/**
* Evaluates an R expression, which must return either TRUE of FALSE, and
* returns the corresponding Java boolean value (true / false).
*
* @param rs
* R string to be evaluated.
* @return Java boolean result.
*/
public boolean isTRUE(String rs) {
boolean result = false;
try {
REXP res = tryEval(rs);
if (res.isLogical()) {
REXPLogical resLog = (REXPLogical) res;
boolean[] boolVec = resLog.isTRUE();
if (boolVec[0]) {
result = true;
}
}
} catch (Exception e) {
showGeneralRError();
e.printStackTrace();
}
return result;
}
示例2: asRList
import org.rosuda.REngine.REXPLogical; //导入依赖的package包/类
public static REXPList asRList(Map<?,?> m) {
RList l = new RList();
for (Object o : m.keySet()) {
Object v = m.get(o);
if (v instanceof Double) {
l.put(o.toString(), new REXPDouble((Double) v));
} else if (v instanceof double[]) {
l.put(o.toString(), new REXPDouble((double[]) v));
} else if (v instanceof Integer) {
l.put(o.toString(), new REXPInteger((Integer) v));
} else if (v instanceof int[]) {
l.put(o.toString(), new REXPInteger((int[]) v));
} else if (v instanceof String) {
l.put(o.toString(), new REXPString((String) v));
} else if (v instanceof String[]) {
l.put(o.toString(), new REXPString((String[]) v));
} else if (v instanceof Boolean) {
l.put(o.toString(), new REXPLogical((Boolean) v));
} else if (v instanceof boolean[]) {
l.put(o.toString(), new REXPLogical((boolean[]) v));
} else if (v instanceof Map) {
l.put(o.toString(), asRList((Map<?,?>) v));
} else if (v instanceof RList) {
l.put(o.toString(), (RList) v);
} else if (v == null) {
l.put(o.toString(), new REXPNull());
} else {
System.err.println("Could not cast object " + o + " : " + v);
}
}
return new REXPList(l);
}