org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named输出结果为向量?
最近在做一个项目,需要用到java调用Rserve执行R语句,代码如下:
xp=c.eval("eperson(economic)"); System.out.println("----eperson(economic).asList()-----");
Object[] array= xp.asList().toArray();
for(int i=0;i<=array.length-1;i++){
System.out.println(array[i]);
}
System.out.println(xp.isVector());
if(xp.isRecursive()){//xp是否为递归对象
for(int i=0;i<xp.length();i++){
System.out.println((xp.asList().get(i)));//values()
System.out.println("---------");
System.out.println((xp.asList().values()));
System.out.println("---------");
System.out.println(xp.asList().toString());
}
}
代码输出结果如下:
----eperson(economic).asList()-----org.rosuda.REngine.REXPString@3b96dc4e[1]
org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named
org.rosuda.REngine.REXPString@57f9a8a0[1]
org.rosuda.REngine.REXPGenericVector@47adcd7f+[3]named
true
org.rosuda.REngine.REXPString@3b96dc4e[1]
---------
RList[org.rosuda.REngine.REXPString@3b96dc4e[1], org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named, org.rosuda.REngine.REXPString@57f9a8a0[1], org.rosuda.REngine.REXPGenericVector@47adcd7f+[3]named]{4}
---------
RList[org.rosuda.REngine.REXPString@3b96dc4e[1], org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named, org.rosuda.REngine.REXPString@57f9a8a0[1], org.rosuda.REngine.REXPGenericVector@47adcd7f+[3]named]{4}
org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named
---------
RList[org.rosuda.REngine.REXPString@3b96dc4e[1], org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named, org.rosuda.REngine.REXPString@57f9a8a0[1], org.rosuda.REngine.REXPGenericVector@47adcd7f+[3]named]{4}
---------
RList[org.rosuda.REngine.REXPString@3b96dc4e[1], org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named, org.rosuda.REngine.REXPString@57f9a8a0[1], org.rosuda.REngine.REXPGenericVector@47adcd7f+[3]named]{4}
org.rosuda.REngine.REXPString@57f9a8a0[1]
---------
RList[org.rosuda.REngine.REXPString@3b96dc4e[1], org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named, org.rosuda.REngine.REXPString@57f9a8a0[1], org.rosuda.REngine.REXPGenericVector@47adcd7f+[3]named]{4}
---------
RList[org.rosuda.REngine.REXPString@3b96dc4e[1], org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named, org.rosuda.REngine.REXPString@57f9a8a0[1], org.rosuda.REngine.REXPGenericVector@47adcd7f+[3]named]{4}
org.rosuda.REngine.REXPGenericVector@47adcd7f+[3]named
---------
RList[org.rosuda.REngine.REXPString@3b96dc4e[1], org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named, org.rosuda.REngine.REXPString@57f9a8a0[1], org.rosuda.REngine.REXPGenericVector@47adcd7f+[3]named]{4}
---------
RList[org.rosuda.REngine.REXPString@3b96dc4e[1], org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named, org.rosuda.REngine.REXPString@57f9a8a0[1], org.rosuda.REngine.REXPGenericVector@47adcd7f+[3]named]{4}
结果并不是我想要的,我希望返回的结果是,能够打印出结果的具体值,即将R语句在R编辑器里运行时后得到结果:
该怎么写代码呢?
回答:
把相关代码贴全,谢谢
以上是 org.rosuda.REngine.REXPGenericVector@2d59a372+[9]named输出结果为向量? 的全部内容, 来源链接: utcz.com/p/171566.html