本文整理匯總了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);
}