[R] JRI - problem to access "stats" package

Geoff Gibbs ggibbs at mango-solutions.com
Fri Jun 26 12:25:14 CEST 2009


Sorry for the confusion, I obviously misunderstood.

I thought you were trying to use R in an eclipse application, not an
application written using eclipse.

As far as I am aware, if the path and R_HOME environment variables are
set then all should work OK.

I think from you examples that the path is set correctly, it may be that
you are using print() to get the value that you are getting null, as I
understand it print() returns invisibly after displaying the value on
screen, as there is no screen the evaluation of print does nothing but
return the result of the call. I suspect you simply want to use
System.out.println(r.eval("p3")).


--

Geoff Gibbs
mangosolutions
data analysis that delivers

Tel +44 (0)1249 767 700

Mob +44 (0)7791 855 620


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of GRAN
Sent: 26 June 2009 11:01
To: r-help at r-project.org
Cc: antoine grimault
Subject: [R] JRI - problem to access "stats" package

Hi Geoff,
Tks a lot for your reply.
There are many points we do not understand.
Can you clarify those one:

- At first, why do you speak about an eclipse plugin ?
We have compiled R and JRI together, so we get a jar file. We finally
include this jar file inside our java project as a referenced libraries.

So we do not understand why you are speaking about plugins and
MANIFEST.MF file.

- Nevermind, which MANIFEST.MF file are you speaking about ? the one of
the JRI plugin ? (if a JRI plugin exists...)

- Last things, you speak about a build.properties. In our project we
haven't any. Is there a work around to do the same ?

Tks for any help,
Antoine





Hi Antoine,

I have got this to work on Windows, the process should be the same for
Linux.

For an eclipse plugin you will need to add the following to your
MANIFEST.MF file:

Bundle-ClassPath: <whatever you normally have>,  lib/JRI.jar
Bundle-NativeCode: /lib/jri.dll; osname=winxp; processor=x86

You will also need to ensure that the *R* executable is in your path and
that *R_HOME* is set.

I did this by creating a simple batch file containing the following in a
directory called *rootfiles* within our feature, the same should work
for a .sh :

 set PATH=%CD%\<*R* install>\exe;%PATH%
 set *R_HOME*=%CD%\<*R* install>
 eclipse.exe

I then added the following line to the build.properties file of the
feature:
*root*=*rootfiles*

This tells eclipse to copy the content of the directory to the *root* of
the application on install.

If you then *run* eclipse from the batch file, it should work.

-- 

Geoff Gibbs
mangosolutions
data analysis that delivers

Tel +44 (0)1249 767 700

Mob +44 (0)7791 855 620


-----Original Message-----
From: *r*-help-bounces at ... 
<http://www.nabble.com/user/SendEmail.jtp?type=post&post=24199629&i=0>
[mailto:*r*-help-bounces at ... 
<http://www.nabble.com/user/SendEmail.jtp?type=post&post=24199629&i=1>]
On Behalf Of GRAN
Sent: 25 June 2009 09:40
To: *r*-help at ... 
<http://www.nabble.com/user/SendEmail.jtp?type=post&post=24199629&i=2>
Subject: [*R*] JRI - problem to access "*stats*" package

Hello,

I am a new *R* user. More precisely, I am working with JRI (on a Eclipse
Java6 project under Ubuntu9).

I have difficulties to access *some* *R* packages (For example: package
"*stats*", object "Normal", function "pnorm").

I have tried many *solutions* to set the *right* path but nothing have
succeed:
For example:
LD_LIBRARY_PATH=${*R_HOME*}/lib:${*R_HOME*}/bin:${*R_HOME*}/library

Inside the  java code, I have also tried such methods:
Note that "*r*" is the *REngine* object coming from the connection to
*R*

           
*r*.eval("dyn.load(\"/home/gran/workspace/*R*-2.9.0/library/*stats*/libs
/*stats* 

.*so*\",
local = TRUE, now = TRUE)");
           *r*.eval("*require*(*stats*)");
           *r*.eval("autoload(\"Normal\", \"*stats*\")");
           *r*.eval("search()");
           *r*.eval("ls(\"Autoloads\")");
           System.out.println(*r*.eval(".Autoloaded"));
           *r*.eval("zval = .95");
           System.out.println(*r*.eval("print(zval)"));
           *r*.eval("p3 = pnorm(3*zval)");
           System.out.println(*r*.eval("print(p3)"));

It gives as a *result*:

           [STRING "*stats*"]
           [*REAL** (0.95)]
           null       <---------- p3 = null because pnorm is unknown

Do you know how to use the "*stats*" package with JRI ?
Thanks in advance,
Antoine

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list