[R] Q: Best-Practice for Swing-GUI calling R-code on Windows?

Till Baumgaertel till.baumgaertel at epost.de
Mon Mar 3 02:25:03 CET 2003


org.omegahat.R.Java.REvaluator e = new
	org.omegahat.R.Java.REvaluator();

	Object val = e.eval("objects()");

	if(val != null) {
		String[] objects = (String[])val;
		for(int i = 0 ; i < objects.length; i++)
			System.err.println("("+i+") " + objects[i]);
	}
hello,

thanks to Philippe Grosjean's work I finally got SJava working (on Windows
XP!!), so that I can call Java-Code from within R.

Now I wanted to write a little Swing-GUI for entering some values and executing
a R-call with them. The results should also be presented in the Java-layer.
If possible, I'd like to see the R-console because I cat() some text what
I like (but not need) to see.

Now I'm wondering what's best practice for that? 

Trying to call R from within Java I get an exception:
java.lang.UnsatisfiedLinkError: eval
        at org.omegahat.R.Java.REvaluator.eval(Native Method)
        at org.omegahat.R.Java.REvaluator.eval(REvaluator.java:86)
        at org.omegahat.R.Java.REvaluator.eval(REvaluator.java:36)
        at SJavaTest.Main.main(Main.java:18)
Exception in thread "main" 

My SJava.DLL is in the PATH as well as the SJava-BaseDir and the Jars in
SJava/org/omegahat/Jars are in the classpath. any suggestions for solving
that?

Calling my GUI from within R is possible using .JNew and invoking show()
on the new instance. I can see the interface, but again I got stuck because
I cannot run R-code.

the code I'd like to try first is the very first example from the "Calling
R from Java"-Tutorial:
#########
org.omegahat.R.Java.REvaluator e = new
	org.omegahat.R.Java.REvaluator();

	Object val = e.eval("objects()");

	if(val != null) {
		String[] objects = (String[])val;
		for(int i = 0 ; i < objects.length; i++)
			System.err.println("("+i+") " + objects[i]);
	}
##########

could anybody give me a hint why this is not working or how i could solve
my original problem the "best" way??

thanks for any hints,
till




More information about the R-help mailing list