如何使用Rcaller一次获得多个结果?例如,我使用
code.addRCode("data<-read.table(\""+ "/home/yo/Documents/Book1.csv"+ "\", header=TRUE,sep=\"\t\")");
caller.setRCode(code);
caller.runAndReturnResult("data");然后,我就可以使用caller.getParser().getNames().size() ...e.g.function了
但是如果我想运行summary(data$pH),我应该怎么做?添加之前的代码?如果“调用者”属于哪一个?感谢所有帮助我的人!
发布于 2013-11-20 18:05:08
你可以在这里找到这个。它演示了如何使用runAndReturnValue方法从RCaller中获取结果
http://stdioe.blogspot.com.tr/search/label/rcaller
发布于 2014-04-13 22:24:44
在R中使用结果列表。例如,您有一个列表
result <- list(a=c(1,2,3), b=3.6, c=5) 调用rcaller.runAndReturnResult(result)后,可以访问变量a、b和c
double[] a = rcaller.getParser().getAsDoubleArray("a");或
int c = rcaller.getParser().getAsIntegerArray("c")[0];使用getNames()方法,您还可以获取'result‘列表中包含的名称。
使用summary()时,不会发生任何变化。假设您在R中调用lm(),如下所示
ols <- lm (y ~ x + z, data=mydata)然后
detailed <- summary(ols)这也是一个列表,作为lm()的返回值。您可以使用以下命令访问此列表的元素
double[] residuals = rcaller.getParser().getAsDoubleArray("residuals");和
double rsquared = rcaller.getParser().getAsDoubleArray("r.squared")[0];summary()之后没有任何变化。回到你的代码
code.addRCode("data<-read.table(\""+ "/home/yo/Documents/Book1.csv"+ "\", header=TRUE,sep=\"\t\")");
caller.setRCode(code);
caller.runAndReturnResult("data");不返回列表,您可以键入
RCode code = new RCode();
code.addRCode("myresult <- list(res1=data$pH, res2=data$anotherVector)");
rcaller.setRCode(code);
caller.runAndReturnResult("myresult");毕竟,
double[] pH = caller.getParser().getAsDoubleArray(pH);返回pH变量。
有关更多信息,请访问官方博客here
https://stackoverflow.com/questions/16962884
复制相似问题