[R] Java interface to R

Richard Piper rpiper at med.usyd.edu.au
Thu Oct 7 09:58:35 CEST 1999

Richard PIper wrote:
> I have been doing some programming with java servlets for data
> collection.
> I was wondering if there is a way to connect to the R-server using java
> to do data analysis. A java-interface or some connection class.
> I think there is some similar facility with SAS, although I have not
> looked at it.
> Richard Piper

To try and answer my own question. It does seem to possible to 
connect to the R process as follows:

	Process p  = Runtime.getRuntime().exec("R --slave");

	OutputStreamWriter o = new OutputStreamWriter(p.getOutputStream());

        BufferedInputStream buffer =
          new BufferedInputStream(p.getInputStream());
        DataInputStream commandResult =
          new DataInputStream(buffer);
 etc ..

It seems to work quite well with limited testing

Intensive Care Unit, RNS Hospital, Sydney.
Phone:	612-9926-8656 or 8617
FAX:	612-9439-8418
Page:	612-9962-9000 No. 248026
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