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());
o.write("data(sleep)\n");
o.write("summary(sleep$extra)\n");
o.write("mean(sleep$extra)\n");
o.write("quit(\"no\")\n");
o.flush();
BufferedInputStream buffer new
BufferedInputStream(p.getInputStream());
DataInputStream commandResult new DataInputStream(buffer);
etc ..
It seems to work quite well with limited testing
Richard
--
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._