The results in R is character or describe.I want to get the resule from R then into Java.I use RCaller.
I use the code below is not works.
code.clear();
code.addRCode("c1<-factor(describe(1:10)$counts)");
code.addRCode("c2<-as.numeric(as.character(c1))");
System.out.println(code.toString());
caller.setRCode(code);
caller.runAndReturnResultOnline("c2");
// String[] cc = caller.getParser().getAsStringArray("de");
double[] cc = caller.getParser().getAsDoubleArray("c2");
System.out.println(caller.getParser().getClass());
for (int i = 0; i < cc.length; i++) {
System.out.println(cc[i]);
}
}
But I use these below is working!
code.clear();
code.addRCode("c1<-factor(3.3:9.3)");
code.addRCode("c2<-as.numeric(as.character(c1))");
System.out.println(code.toString());
caller.setRCode(code);
caller.runAndReturnResultOnline("c2");
// String[] cc = caller.getParser().getAsStringArray("de");
double[] cc = caller.getParser().getAsDoubleArray("c2");
System.out.println(caller.getParser().getClass());
for (int i = 0; i < cc.length; i++) {
System.out.println(cc[i]);
}
}
why? If I want get character or other type data from R to Java use RCaller,what can I do?Thanks!!!
因为您使用getAsDoubleArray()返回一个双精度数据类型的数组。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.