what if you do something like this (changing line and line numbers for your needs)?
RConnection c = new RConnection(); double[][] test = { { 1.0D, 2.0D }, { 3.0D, 4.0D } }; c.assign("res", test[0]); for (int i = 1; i < 2; i++) { c.assign("tmp", test[i]); c.eval("res<-rbind(res,tmp)"); } REXP x = c.eval("sum(res)"); System.out.println(x.asString());
this returns 10, as expected, but however, it
String s = c.eval("rowSums(res)").asString(); System.out.println(s);
does not print what he suggested, it just returns 3 , maybe my installed Ubuntu RServe is broken and cannot print everything after a space in the result line 3 7 :
> rowSums(d) c1 c2 3 7
and I can also find good examples :(
source share