[R] Calling R from Java

From: zana adeb <xenamaa_at_yahoo.com>
Date: Sat 08 Jul 2006 - 00:06:43 EST


Madam,    

  I've read your answer :

  ///////////////////////////////////////
  Here are other alternatives that are easy to implement and that you should consider depending on what you want to do:

1- one is to use R in batch mode ie you create a file in your java code with all the R commands and send it to R (via Process pc=Runtime.getRuntime().exec(Rcall); )and then R creates an outputfile with all the results.
The matter with this is that there is no interactivity, variables are not kept, you have to parse the outputfile, ... (see the above article (see FFinterface))

2- another one is to use the R server developed by Simon Urbanek:

http://stats.math.uni-augsburg.de/Rserve/

A java frontend is provided with the server, which allows to communicate easily with R and which sends back results in a java object. So for each connection to the server you have a R environment where all the variable generated are kept until you close the connection and from you java code it is as simple as this example: REXP mean = c.eval("mean"+i+"<-apply("+data+"[,data.cl=="+(i-1)+"],1,mean.na)");

This is what I'am using in my application and I am quite satisfied with it.

//////////////////////////////

  For the first solution, I have not understood how I get the results from R???    

  For the second solution, I didn't understant the instruction, i'm beginner in R and Java???   I ve understood that Rserve is a server that I should install server R, R and the JDK for the jav???    

  Thank you in advance,    

  XENA                  


        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 08 00:14:51 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 08 Jul 2006 - 02:15:44 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.