Hi, I'm trying to use j2r with the sensitivity R package http://cran.r-project.org/web/packages/sensitivity/index.html I've installed R 2.10.1, sensitivity 1.4.0 and Rserve 0.6-1. Following commands are OK in the R shell: library('sensitivity') fast99(model = NULL,factors=3,n=1000,q='qunif',q.arg=list(min=-1,max=1)) but if I try the same with j2r, I've got: Exception in thread "main" java.lang.NullPointerException at org.nuiton.j2r.net.RNetEngine.convertResult(RNetEngine.java:302) at org.nuiton.j2r.net.RNetEngine.convertResult(RNetEngine.java:293) at org.nuiton.j2r.net.RNetEngine.convertResult(RNetEngine.java:293) at org.nuiton.j2r.net.RNetEngine.convertResult(RNetEngine.java:293) at org.nuiton.j2r.net.RNetEngine.eval(RNetEngine.java:169) at org.nuiton.j2r.RProxy.eval(RProxy.java:154) My java code is: Engine rengine = new RProxy(); rengine.eval("library('sensitivity')"); rengine.eval("fast99(model = NULL,factors=3,n=1000,q='qunif',q.arg=list(min=-1,max=1))"); If someone have an idea… -- Nicolas Dumoulin Ingénieur d'études - Cemagref, LISC +33 (0)4.73.44.07.29
After a quick debug, I can see that the problem is with this line: rexp.getAttribute(RInstructions.ATTRIBUTE_NAMES).asStrings() The NPE occurs because rexp.getAttribute(RInstructions.ATTRIBUTE_NAMES) is null with - RInstructions.ATTRIBUTE_NAMES = "names" - and rexp is a REXPLanguage instance containing - a REXPSymbol "-" - a REXPDouble "1.0" -- Nicolas Dumoulin Ingénieur d'études - Cemagref, LISC +33 (0)4.73.44.07.29
Le 12/05/2010 12:00, Nicolas Dumoulin a écrit :
After a quick debug, I can see that the problem is with this line: rexp.getAttribute(RInstructions.ATTRIBUTE_NAMES).asStrings()
The NPE occurs because rexp.getAttribute(RInstructions.ATTRIBUTE_NAMES) is null with - RInstructions.ATTRIBUTE_NAMES = "names" - and rexp is a REXPLanguage instance containing - a REXPSymbol "-" - a REXPDouble "1.0"
Thanks, I had a look to the code in R, and I got the attribute "names" containing a list of String : $names [1] "model" "M" "s" "omega" "X" "call" I will try to go further, but as nuiton-j2r do not modify the rexp return from R (and gotten from jri or rserve libraries), i guess this could be also a bug from there. Jean
Le mercredi 12 mai 2010 12:23:35 Jean Couteau, vous avez écrit :
I will try to go further, but as nuiton-j2r do not modify the rexp return from R (and gotten from jri or rserve libraries), i guess this could be also a bug from there.
You mean a bug in Rserve? -- Nicolas Dumoulin Ingénieur d'études - Cemagref, LISC +33 (0)4.73.44.07.29
Le 12/05/2010 12:00, Nicolas Dumoulin a écrit :
After a quick debug, I can see that the problem is with this line: rexp.getAttribute(RInstructions.ATTRIBUTE_NAMES).asStrings()
The NPE occurs because rexp.getAttribute(RInstructions.ATTRIBUTE_NAMES) is null with - RInstructions.ATTRIBUTE_NAMES = "names" - and rexp is a REXPLanguage instance containing - a REXPSymbol "-" - a REXPDouble "1.0"
Just a question, which version of j2r are you using ?
Le 12/05/2010 11:49, Nicolas Dumoulin a écrit :
Hi,
Hi
I'm trying to use j2r with the sensitivity R package http://cran.r-project.org/web/packages/sensitivity/index.html
I've installed R 2.10.1, sensitivity 1.4.0 and Rserve 0.6-1.
Following commands are OK in the R shell: library('sensitivity') fast99(model = NULL,factors=3,n=1000,q='qunif',q.arg=list(min=-1,max=1))
but if I try the same with j2r, I've got: Exception in thread "main" java.lang.NullPointerException at org.nuiton.j2r.net.RNetEngine.convertResult(RNetEngine.java:302) at org.nuiton.j2r.net.RNetEngine.convertResult(RNetEngine.java:293) at org.nuiton.j2r.net.RNetEngine.convertResult(RNetEngine.java:293) at org.nuiton.j2r.net.RNetEngine.convertResult(RNetEngine.java:293) at org.nuiton.j2r.net.RNetEngine.eval(RNetEngine.java:169) at org.nuiton.j2r.RProxy.eval(RProxy.java:154)
My java code is: Engine rengine = new RProxy(); rengine.eval("library('sensitivity')"); rengine.eval("fast99(model = NULL,factors=3,n=1000,q='qunif',q.arg=list(min=-1,max=1))");
If someone have an idea…
Ok, it is trying to convert the result and got a NPE trying to do it. As you do not use the result from R in your code, you could replace the eval() method by the voidEval() one (that do not try to return the result from R and so do not make the conversion). This should make your example work. I'll have a look to the NPE though because it should not happen. Best regards, Jean
Le mercredi 12 mai 2010 12:05:52 Jean Couteau, vous avez écrit :
Ok, it is trying to convert the result and got a NPE trying to do it. As you do not use the result from R in your code, you could replace the eval() method by the voidEval() one (that do not try to return the result from R and so do not make the conversion).
The give code is an example, but I need the object indeed ;-) Maybe, I can try to simplify the object in R script to help j2r magic convertor… Thanks -- Nicolas Dumoulin Ingénieur d'études - Cemagref, LISC +33 (0)4.73.44.07.29
Le 12/05/2010 12:10, Nicolas Dumoulin a écrit :
Le mercredi 12 mai 2010 12:05:52 Jean Couteau, vous avez écrit :
Ok, it is trying to convert the result and got a NPE trying to do it. As you do not use the result from R in your code, you could replace the eval() method by the voidEval() one (that do not try to return the result from R and so do not make the conversion).
The give code is an example, but I need the object indeed ;-)
I guess that what you want is the experiment design so if you call your R object a, the a$X data.frame. What you could do is something like : engine.voidEval("a<-fast99..."); RDataframe myExperiment = (RDataframe)engine.eval("a$X");
Maybe, I can try to simplify the object in R script to help j2r magic convertor…
It is always better to get the basic types from R instead of complicated custom R objects (such as a fast99 object ;) ) In J2R, you can work with data.frames, lists, or the basic java types. Hope this helps, Jean
Le mercredi 12 mai 2010 12:23:38 Jean Couteau, vous avez écrit :
I guess that what you want is the experiment design so if you call your R object a, the a$X data.frame.
Yes, it was I mean. But, as you may know, I need then the complete returned object for the analysis phase with the tell() method. So, I can store the result in a R variable, and fetch only $X, but as I use Rserve, I'm not what will happen if two users make a fast99 exploration on the same server…
Hope this helps, Jean
Thanks -- Nicolas Dumoulin Ingénieur d'études - Cemagref, LISC +33 (0)4.73.44.07.29
Le 12/05/2010 12:31, Nicolas Dumoulin a écrit :
Le mercredi 12 mai 2010 12:23:38 Jean Couteau, vous avez écrit :
I guess that what you want is the experiment design so if you call your R object a, the a$X data.frame.
Yes, it was I mean. But, as you may know, I need then the complete returned object for the analysis phase with the tell() method. So, I can store the result in a R variable, and fetch only $X, but as I use Rserve, I'm not what will happen if two users make a fast99 exploration on the same server…
You are safe this way, because on Rserve, you have a session per user, so you can assign variables without any problem and can use the tell method on the stored object, it will never be altered by other users. But you must always use the same REngine instance to stay on the smae user session.
Hope this helps, Jean
Thanks
Le mercredi 12 mai 2010 14:11:56 Jean Couteau, vous avez écrit :
Le 12/05/2010 12:31, Nicolas Dumoulin a écrit :
Le mercredi 12 mai 2010 12:23:38 Jean Couteau, vous avez écrit :
I guess that what you want is the experiment design so if you call your R object a, the a$X data.frame.
Yes, it was I mean. But, as you may know, I need then the complete returned object for the analysis phase with the tell() method. So, I can store the result in a R variable, and fetch only $X, but as I use Rserve, I'm not what will happen if two users make a fast99 exploration on the same server…
You are safe this way, because on Rserve, you have a session per user, so you can assign variables without any problem and can use the tell method on the stored object, it will never be altered by other users. But you must always use the same REngine instance to stay on the smae user session.
I was not sure of that. Thank you for the confirmation. -- Nicolas Dumoulin Ingénieur d'études - Cemagref, LISC +33 (0)4.73.44.07.29
participants (2)
-
Jean Couteau -
Nicolas Dumoulin