Skip to content
Prev 16062 / 63424 Next

Calling R functions from Java

On May 2, 2005, at 2:55 AM, D0c wrote:

            
There are several ways - you can use one of the R devices (e.g. jpeg/ 
png, pdf or GDD) to create a file and then transport it to the client  
using Rconnection.openFile (or use it locally depending on your  
setup) or you can use one of the special devices to plot directly -  
xGD or JavaGD.
Something like
String s = c.eval("paste(capture.output(summary 
(data)),collapse='\n')").asString();
then add the string to whatever widget you want ... Maybe a better  
place for discussing Rserve is http://www.rosuda.org/lists.shtml

If you don't need the client/server separation you may consider JRI  
(as used by JGR) or SJava (from Omegahat) instead - both embed R into  
Java directly i.e. you have only one process running. JRI works  
nicely with rJava and JavaGD so you have a native Java graphics  
device that you can embed in your AWT/Swing windows. Rserve is better  
for applications with several clients such as web servers. SJava is  
more general, but is not easy to setup on non-unix platforms (your  
mileage may vary).

Cheers,
Simon