[Rd] Re: Calling R functions from Java
Simon Urbanek
simon.urbanek at r-project.org
Mon May 2 14:33:42 CEST 2005
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
More information about the R-devel
mailing list