[英]How to resolve exception “eval failed, request status: error code: 127” in R and Java?
[英]Rserve Exception “eval failed, request status: error code: 127”
我試圖使用Rserve從Java執行一些r代碼:
try {
RConnection conn = new RConnection();
conn.eval("write.csv(PoS, file = 'C:/test/PoS.csv',row.names=FALSE)");
} catch (REngineException eR) {
System.err.println("Exception: "+ eR);
throw new TestException("syntax error on eval on R code");
} catch(Exception e){
e.printStackTrace();
throw new TestException("parseAndEval did not generate an exception on syntax error" );
}
我收到評估失敗的錯誤。 但是我可以在R中成功執行Rcode:
write.csv(PoS, file = 'C:/test/PoS.csv',row.names=FALSE)
我確定Rserve()
已在R端啟動,並且其他語句如
conn.eval("iris");
是可能的。
我已經解決了這個問題。 每次我建立新的Rconnection時,都需要重新加載矩陣PoS
,或者將其保存在默認的工作區映像中。
要獲取正確的錯誤消息,請使用此代替簡單的eval
REXP rResponseObject = rServeConnection.parseAndEval("try(eval("+R_COMMAND_OR_SOURCE_FILE_PATH+"),silent=TRUE)");
if (rResponseObject.inherits("try-error")) {
LOGGER.error("R Serve Eval Exception : "+rResponseObject.asString());
}
該記錄器打印從R引發的確切錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.