[R] Controlling R from Java

Marc Grushcow Marc.Grushcow at ntt.ca
Tue Dec 12 21:38:16 CET 2000

I'd like to run R (LINUX) under Java. I can create the process and connect to
stdin and stdout. I can send commands in and get output back.  I don't know how
to determine when the output is complete - there is no trailing "prompt".

For example, if I send "ls()\n" what I get back is:
> ls()

Each of the above two lines is terminated with a 0x0A. I would have expected

Then I could parse for the "\n> " and know when the output is complete. The
problem with checking for data availability on the input stream is that it is
unreliable. R's output buffer might flush unpredictably and/or the task
switching OS might cause R to stop after one buffer is full but before another
is completed.  In any case, it is the usual problem of one program trying to
parse another's output in a time sharing environment.

I'm sure that this problem has been solved before.  Any suggestions would be

mailto:Marc.Grushcow at NTT.ca		http://www.NTT.ca

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list