From simon.urbanek at r-project.org  Mon May  2 14:33:42 2005
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Mon May  2 14:33:51 2005
Subject: [Rd] Re: Calling R functions from Java
In-Reply-To: <2667b21305050123557078b47c@mail.gmail.com>
References: <2667b213050429062157c4c124@mail.gmail.com>
	<2667b21305050123557078b47c@mail.gmail.com>
Message-ID: <542BC889-60CF-44F7-8E25-92A88E6A4A0D@r-project.org>

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

> Hey guys thanks for the help. I found Rserve to be a solution i can  
> work with. i'll just use the JRClient to connect to Rserve. However  
> i have another problem. How can i get a nice graph from Rserve  
> using JRCLient using the plot() function?

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.

> Or for that matter a simple summary() of a dataset to be printed on  
> screen (eg JOptionPane)?

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


[Rd] Re: Calling R functions from Java
Simon Urbanek