title: Call R from Java using JRI, how to cast return value
body: <p>I'm executing some R commands from Java using JRI.I want to use the results from R in my Java for further calculations but I have no idea how cast the returned object.</p>
  
  <h2>call code in Java:</h2>
  
  <pre><code>REXP x;
  System.out.println(x = rengine.eval("source(\"/..../TS.R\")"));
  System.out.println( x.asVector().elementAt(0));
  </code></pre>
  
  <hr>
  
  <h2>last line from R code:</h2>
  
  <pre><code>eq_all[length(eq_all)-1]
  </code></pre>
  
  <p>--</p>
  
  <h2>output in Java console:</h2>
  
  <pre><code>[VECTOR ([REAL* (3.050462038715372)], [BOOLi* ])]
  [REAL* (3.050462038715372)]
  </code></pre>
  
  <hr>
  
  <p>"3.050462038715372" is the right value but how can I access it in Java?</p>
  
  <p>best regards,
  Immanuel</p>
  
  <p>PS. related question without answer:
  <a href="https://stackoverflow.com/questions/7471689/converting-rexp-object-to-a-double-array-java-r">Converting REXP object to a double array (Java/R)</a></p>