Skip to content

Instantly share code, notes, and snippets.

@pgtwitter
Last active August 29, 2015 14:13
Show Gist options
  • Save pgtwitter/203cd2c2ff78bcb4c565 to your computer and use it in GitHub Desktop.
Save pgtwitter/203cd2c2ff78bcb4c565 to your computer and use it in GitHub Desktop.
sqrt(36)
package rJava;
import org.rosuda.JRI.REXP;
import org.rosuda.JRI.Rengine;
public class RSample {
public static void main(String[] args) {
System.err.println(System.getenv("R_HOME"));
System.err.println(System.getenv("java.library.path"));
Rengine engine = new Rengine(new String[] {
"--no-save"
}, false, null);
engine.assign("a", new int[] {
36
});
REXP result = engine.eval("sqrt(a)");
System.out.println(result.asDouble());
engine.end();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment