There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:hi Mike,
at the office we use R a lot but no java, and at home I use java a little but I have no direct usages for R sofar.
So, show us the code and your problem, since "never shot is always a miss".
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:Sorry for responding so late!
A few questions about some things that are not clear to me (note that I have never done anything with R and Java together, at the office we have no java unfortunately):
1) does your java program write a complete R-program about Box M test, up and ready to be executed in R?
2) or does your java program simply (well, simply...) do the equivalent of R's Box M?
3) What are these 'rConnection' and 'TextConnection'?
Tomorrow att the office I'll try to load the 'biotools' package, to practise a bit. Last time I used a Box M test... ehh, can't remember! But that won't be a problem.
I'll do my best!
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:hi Mike,
It was not much use doing it at the office, for lack of java, so tried it at home this evening.
Bit of a setback, I'm afraid.
Loaded everything in R (rJava, biotools and Rserve), oke
created a project in NetBeans, and copied rTest.java into it (is part of the rJava package in R)
added JRI.jar, JRIEngine.jar and REngine.jar to the library of that project
added the %RHOME%\bin and %R_HOME%\library\rJava\jri to the PATH in w10
Then tried to run rtest.java, but I got the following errors:
run:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
java.lang.UnsatisfiedLinkError: D:\R-3.1.2\library\rJava\jri\jri.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at org.rosuda.JRI.Rengine.<clinit>(Rengine.java:19)
at rjava.rtest.main(rtest.java:63)
It drives me nuts! Any idea what is happening here?
Edit: I was following this (rather old) website: http://www.studytrails.com/r/r-and-java-jri-using-netbeans/
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:hi Mike,
I'll certainly give it a try! Being able to call R from within java sounds fantastic. The boxM test that you used works a treat in R, so that's not the problem. Well, hopefully I can get it to work and try to reproduce your problem. That'll be this evening.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:hi Mike,
I tried following your StackOverflow link. Problem is: I don't really understand what these guys are saying, I seem to be too big a dummy for that. But I copied dll's all over the place, added some in my Java/bin map, editted PATH, JAVA_HOME, R_HOME and the lot, gosh I really didn't know what I was doing. But the JRI native error disappeared, so did the IA 32 dll misery, only to be replaced by some dependency error. Hmm, I would not be surprised if my Java stopped working...
Anyway, I just noticed that in that StackOverflow topic there was, at the end, a detailed instruction that just looks I might be able to understand. I'll give that a try tonight!
If I don't get it up and runing tomorrow, then try StackOverflow otherwise you'll be retired before I get somewhere.
But meanwhile: the error you report says that 'boxMvariable[,-5]' has undefined columns selected. Can you mimic the simple expression 'c <- dim(boxMVariable)' and see how many columns there are? (c should give 150 by 5). Or mimic 'c <- boxMVariable[,-5]'? Or simple 'c <- boxMvariable[,5]'? See if you get any errors with that.
Well, I'm not giving up.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:I just tried to copy your code line for line into a java class. But I run into problems with this:
I get an error "RList cannot be converted to List"
I must change it to
before the error disappeared. But then I got an error at these lines:
The error being that JRI.Rlist cannot be converted to REngine.RList.
Do I miss something?
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:hi Mike,
indeed with re.assign(....) it doesn't work for me too. You are using the instance 'rConsole'. Where do you get this instance from?
If I do 'RConsole rc = ---' I get the error tha 'RConsole' cannot be found.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:Hmmm, bad luck here.
First of all: I do not have the package '...REngine.Rserve'. Don't know how come.
I had a look at RForge and I saw Rserve in the jar-file 'RserveEngine.jar' that contained the Rserve package. I downloaded it and added it to my library.
So far so good.
But if I run this code:
I keep getting the error:
Exception in thread "main" org.rosuda.REngine.Rserve.RserveException: Cannot connect: Connection refused: connect
at org.rosuda.REngine.Rserve.RConnection.<init>(RConnection.java:88)
at org.rosuda.REngine.Rserve.RConnection.<init>(RConnection.java:60)
at org.rosuda.REngine.Rserve.RConnection.<init>(RConnection.java:44)
at rjava.Piet.<init>(Piet.java:26) // that's line 17 in the code above
at rjava.Piet.main(Piet.java:22)
I have R running with the package Rserve.
I have googled for the error, but so far no clear causes.
But my use is not setting variables in R from Java, but for instance to get samples from distributions back in Java, and that part works beautifully.
Piet
There are three kinds of actuaries: those who can count, and those who can't.
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|