java - Problems with JRI -



java - Problems with JRI -

i trying run illustration of jri , beingness unsuccessful, here link example. http://blog.comsysto.com/2013/07/10/java-r-integration-with-jri-for-on-demand-predictions/

import org.rosuda.jri.rengine; import org.rosuda.jri.rexp; public class hellorworld { rengine rengine; // initialized in constructor or autowired public void hellorworld() { rengine.eval(string.format("greeting <- '%s'", "hello r world")); rexp result = rengine.eval("greeting"); system.out.println("greeting r: "+result.asstring()); } }

this error console gives me.

exception in thread "main" java.lang.nullpointerexception @ org.roulette.games.hellorworld.hellorworld(hellorworld.java:10) @ org.roulette.games.hellorworld.main(hellorworld.java:17)

as far know have external jri 2014-10-19 jar attached project correctly. have r 3.1.2 installed , have rjava 0.9-6 bundle installed.

line 10 "rengine.eval(string.format("greeting <- '%s'", "hello r world"));".

and line 17 "hello.hellorworld();".

please allow me know if have thought why it's throwing these exceptions.... :)

try this: works:

package stackoverflow; import org.rosuda.jri.rexp; import org.rosuda.jri.rengine; /** * * @author yschellekens */ public class stackoverflow { public static void main(string[] args) throws exception { string[] rargs = {"--vanilla"}; rengine rengine = new rengine( rargs, false, null); rengine.eval("greeting <- '%hello r world'"); rexp result = rengine.eval("greeting"); system.out.println("greeting r: "+result.asstring()); } }

notice had several errors, including not including main class, , not creating proper constructor.

java r rjava jri

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -