Reading R-Errors through JRI

可紊 提交于 2019-12-12 13:05:44

问题


i'm using JRI, to talk to R through Java. If i try to get the result of my R-Code as Double i get a NullPointer. Normally this is caused by an error of R. Is it possible to get the output of the R-Console into Java in order to read the error?


回答1:


Ok. Here is what I did, to solve the problem.

because my REngine is a singleton i was able to perform those R-Expressions, after the creation:

re.eval("log<-file('"+filepath+"')");
re.eval("sink(log, append=TRUE)");
re.eval("sink(log, append=TRUE, type='message')");

this codes writes every R-Output into the file specified by the String filepath. For non-singletons i would recommend to extend the REngine...



来源:https://stackoverflow.com/questions/16916142/reading-r-errors-through-jri

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!