本文整理汇总了Java中org.rosuda.JRI.Rengine.assign方法的典型用法代码示例。如果您正苦于以下问题:Java Rengine.assign方法的具体用法?Java Rengine.assign怎么用?Java Rengine.assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.rosuda.JRI.Rengine
的用法示例。
在下文中一共展示了Rengine.assign方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.rosuda.JRI.Rengine; //导入方法依赖的package包/类
public void run() {
REngineManager rengineManager = REngineManager.getInstance();
Rengine re = rengineManager.getREngine();
try {
REXP RarResiduals;
REXP RarPreds;
re.assign("valseries", tSeries);
re.eval("valseries.ar=ar.mle(valseries, aic=FALSE, order.max="+ arOrder + ")");
RarResiduals=re.eval("valseries.ar$resid["+initialOffset + ":length(valseries)]");
RarResiduals=re.eval("valseries.ar$resid["+initialOffset + ":length(valseries)]");
this.arResiduals = RarResiduals.asDoubleArray();
re.eval("valpred=predict(valseries.ar,n.ahead="+predStep+")");
RarPreds=re.eval("valpred$pred");
this.arPreds = RarPreds.asDoubleArray();
} catch (Exception e) {
System.out.println("EX:"+e);
e.printStackTrace();
rengineManager.endEngine();
}
}
示例2: mostEnabledDisabled
import org.rosuda.JRI.Rengine; //导入方法依赖的package包/类
private static void mostEnabledDisabled(Rengine re){
re.eval("maxEnabledFeatures <- as.numeric(as.character((data.frame(table(data$nbFeatures))[nrow(data.frame(table(data$nbFeatures))),1])))");
re.eval("minEnabledFeatures <- as.numeric(as.character((data.frame(table(data$nbFeatures))[1,1])))");
re.eval("mostEnabled <- data[grep(paste(\"\\\\b\",maxEnabledFeatures,\"\\\\b\",sep=\"\"),data$nbFeatures),]");
re.eval("mostDisabled <- data[grep(paste(\"\\\\b\",minEnabledFeatures,\"\\\\b\",sep=\"\"),data$nbFeatures),]");
// Select first one
re.eval("mostEnabledDisabledFirstOne <- rbind(mostEnabled[1,],mostDisabled[1,])");
extractBugProportion(re,"mostEnabledDisabledFirstOne",0,"mostEnabledDisabledFirstOne");
System.out.println("************************");
System.out.println("most-enabled-disabled (first-one):");
System.out.println("Sample size: "+re.eval("nrow(mostEnabledDisabledFirstOne)").asInt());
System.out.println("Failures: "+re.eval("data.frame(table(mostEnabledDisabledFirstOne$Build))[1,1]").asInt());
System.out.println("Faults: "+MOST_ENABLED_DISABLED_FIRST_ONE_FAULTS);
// Select randoms
for(int i =0; i<NUMBER_OF_RANDOMS;i++){
re.eval(String.format("randomMostEnabled%s <- mostEnabled[sample(nrow(mostEnabled),1),]", i));
re.eval(String.format("randomMostDisabled%s <- mostDisabled[sample(nrow(mostDisabled),1),]", i));
re.eval(String.format("randomMostEnabledMostDisabled%s <- rbind(randomMostEnabled%s, randomMostDisabled%s)", i,i,i));
extractBugProportion(re,"randomMostEnabledMostDisabled"+i,i,"mostEnabledDisabledRandom");
extractFailures(re, "randomMostEnabledMostDisabled"+i, i, "mostEnabledDisabled");
}
System.out.println("************************");
System.out.println("most-enabled-disabled (randoms):");
System.out.println("Sample size: "+re.eval("nrow(randomMostEnabledMostDisabled0)").asInt());
//TODO extract failures
re.assign("mostEnabledDisabledRandomsFailures", MOST_ENABLED_DISABLED_RANDOMS_FAILURES);
System.out.print("Failures: "+re.eval("mean(mostEnabledDisabledRandomsFailures)").asDouble());
System.out.println(" ( "+re.eval("sd(mostEnabledDisabledRandomsFailures)").asDouble()+" ) ");
System.out.println("Min: "+re.eval("min(mostEnabledDisabledRandomsFailures)").asInt()+ "Max: "+re.eval("max(mostEnabledDisabledRandomsFailures)").asInt());
re.assign("mostEnabledDisabledRandomsFaults", MOST_ENABLED_DISABLED_RANDOMS_FAULTS);
System.out.print("Faults: "+re.eval("mean(mostEnabledDisabledRandomsFaults)").asDouble());
System.out.println(" ( "+re.eval("sd(mostEnabledDisabledRandomsFaults)").asDouble()+" ) ");
System.out.println("Min: "+re.eval("min(mostEnabledDisabledRandomsFaults)").asInt()+ "Max: "+re.eval("max(mostEnabledDisabledRandomsFaults)").asInt());
}
示例3: run
import org.rosuda.JRI.Rengine; //导入方法依赖的package包/类
public void run() {
// just making sure we have the right version of everything
REngineManager rengineManager = REngineManager.getInstance();
Rengine re = rengineManager.getREngine();
try {
REXP RpredUVar;
REXP RpredLVar;
//re.eval("library(tseries)"); // not required since REngineManager.initREngine() calls it once when the REngine is created
re.assign("nyse", tSeries);
re.eval("nyse.g=garch(nyse, order=c("+ garchOrder + ","+ archOrder + "))");
re.eval("u=tseries:::predict.garch(nyse.g,genuine=TRUE)");
//System.out.println(RpredUVar=re.eval("u["+ initialOffset + ":dim(u)[1],1]"));
//System.out.println(RpredLVar=re.eval("u["+ initialOffset + ":dim(u)[1],2]"));
RpredUVar=re.eval("u[dim(u)[1],1]");
RpredLVar=re.eval("u[dim(u)[1],2]");
predUVar = RpredUVar.asDouble();
predLVar = RpredLVar.asDouble();
} catch (Exception e) {
System.out.println("EX:" + e);
e.printStackTrace();
rengineManager.endEngine();
}
}