本文整理汇总了Java中org.rosuda.JRI.RList类的典型用法代码示例。如果您正苦于以下问题:Java RList类的具体用法?Java RList怎么用?Java RList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RList类属于org.rosuda.JRI包,在下文中一共展示了RList类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRResult
import org.rosuda.JRI.RList; //导入依赖的package包/类
private void processRResult(REXP rResult, Map<String, Object> predictedValues, String name) {
switch(rResult.getType()) {
case REXP.XT_ARRAY_DOUBLE:
double[] doubleArray = rResult.asDoubleArray();
for(int i=0; i<doubleArray.length; i++) {
predictedValues.put(name + "_" + Integer.toString(i), doubleArray[i]);
}
break;
case REXP.XT_ARRAY_INT:
int[] intArray = rResult.asIntArray();
for(int i=0; i<intArray.length; i++) {
predictedValues.put(name + "_" + Integer.toString(i), intArray[i]);
}
break;
case REXP.XT_ARRAY_STR:
String[] strArray = rResult.asStringArray();
for(int i=0; i<strArray.length; i++) {
predictedValues.put(name + "_" + Integer.toString(i), strArray[i]);
}
break;
case REXP.XT_BOOL:
boolean bool = rResult.asBool().isTRUE();
predictedValues.put(name, bool);
break;
case REXP.XT_DOUBLE:
double doub = rResult.asDouble();
predictedValues.put(name, doub);
break;
case REXP.XT_INT:
int integ = rResult.asInt();
predictedValues.put(name, integ);
break;
case REXP.XT_STR:
String str = rResult.asString();
predictedValues.put(name, str);
break;
case REXP.XT_VECTOR:
RVector rVector = rResult.asVector();
Map<String, Object> vectorSubResult = new HashMap<String, Object>();
for (Object vName : rVector.getNames()) {
processRResult(rVector.at(vName.toString()), vectorSubResult, vName.toString());
}
predictedValues.put(name, vectorSubResult);
break;
case REXP.XT_LIST:
RList rList = rResult.asList();
Map<String, Object> listSubResult = new HashMap<String, Object>();
for(String lName : rList.keys()) {
processRResult(rList.at(lName), listSubResult, lName);
}
predictedValues.put(name, listSubResult);
break;
default:
log.log(Level.WARNING, "Unsopported R expression/result type " + rResult.getType() + ". Will not add it to predicted values");
}
}