Skip to content

Using R in Java?

5 messages · nicro, Christian Ruckert, Roy Mendelssohn - NOAA Federal +2 more

#
Hi 2 questions-
1. Is there a package that will allow me to run R scripts (entirely) from
Java?
2. If so, is there a way to capture the output of those scripts, (including
images) and embed them in my SWT java app?

My challenge is I have a java app that does some statistical chores- it
would be fantastic if the users could use their R skills to modify a script
in whatever R environment they like and then my app could use that script to
calculate the results and display them in the app.

I have found StatET and JavaGD with rJava/JRI and read through all the
docs... its seems possible that some combination may give me what I want,
but its not very clear.

Any suggestions anyone?

Thanks!
#
nicro schrieb:
The JRI part from the rJava package does exactly what you want. Simple 
data types like numbers or strings are directly returned as java 
objects. But I'm afraid for the images you have to use the files system 
indirection.

If needed I can post an example,

Christian
#
See also Biocep:

http://biocep-distrib.r-forge.r-project.org/

-Roy M.
On Feb 19, 2009, at 10:42 AM, Christian Ruckert wrote:

            
**********************
"The contents of this message do not reflect any position of the U.S.  
Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: Roy.Mendelssohn at noaa.gov (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected"
#
Wow, very interesting!  The netbeans example looks similar to what I
want, which is based on Eclipse RCP.

I will explore this more, as well as the JRI indirect method suggested
by Christian.

Thanks!

-----Original Message-----
From: Roy Mendelssohn [mailto:Roy.Mendelssohn at noaa.gov] 
Sent: Thursday, February 19, 2009 10:47 AM
To: Christian Ruckert
Cc: Bryan Coon; r-help at r-project.org
Subject: Re: [R] Using R in Java?

See also Biocep:

http://biocep-distrib.r-forge.r-project.org/

-Roy M.
On Feb 19, 2009, at 10:42 AM, Christian Ruckert wrote:

            
http://www.R-project.org/posting-guide.html
**********************
"The contents of this message do not reflect any position of the U.S.  
Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: Roy.Mendelssohn at noaa.gov (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected"



THIS EMAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT(S) AND MAY CONTAIN CONFIDENTIAL INFORMATION. ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, PLEASE CONTACT THE SENDER BY REPLY EMAIL AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE.
3 days later
#
Hi nicro,

There's a way that we use a lot in our projects which allows Java to call R
and capture the text/table/image outputs. In Java We call 'Rscript
exampleScript.R' via shell command. The R script should generate an XML file
when it finishes, describing what output was generated, then java can pick
them all up.

We are also trying to look into Biocep -- it looks impressive in terms of
its capability in handling R and bridging Java-R.

Hope this helps.

Thanks
Fan