-2

I have the following code.

public void rFun() {

    Rsession instance = RConnect.getInstance();
    instance.eval("load(\".RData\")");

    REXP x = instance.eval("xyz <- c(10,20,30)");

    try {
        System.out.println("xyz -> "+x.asString());

    } catch (REXPMismatchException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

I am creating an RList, but when I try to get the list in java it is displaying only the first value i.e. 10.

How to get all the values of the list?

Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265
Abhi
  • 96
  • 2
  • 7

2 Answers2

1

You can use a for loop and get the values.

for(int i=0; i<x.asInteger(); i++){
    System.out.println(x.asStrings[i]);
}
Leo
  • 5,017
  • 6
  • 32
  • 55
1

You can also use

x.asDoubleMatrix()[][] 

for data frames or matrices containing numeric or integer values.

Leo
  • 5,017
  • 6
  • 32
  • 55