r - RNetLogo not working on macOS Sierra and Windows -
i using macos sierra , r version 3.4.1 , java version "1.8.0_144". trying simple example adapted rnetlogo manual:
require(rnetlogo) require(tidyverse) require(extrafont) loadfonts() nl.path <- "/applications/netlogo 6.0.1" nlstart(nl.path) model.path <- "/models/sample models/earth science/fire.nlogo" absolute.model.path <- paste(nl.path,model.path,sep="") nlloadmodel(absolute.model.path)
but command nlloadmodel gives following error:
error in .jcall(nl.obj, "v", "loadmodel", .jnew("java/lang/string", model.path)) : rcallmethod: invalid object parameter
this happens in windows java version 1.8.
using fire.nlogo model in macos sierra, found 2 solutions (see manual of rnetlogo): first, gui=false
sys.setenv(noawt=1) require(rnetlogo) nl.path <- "/applications/netlogo 6.0.1/java" nl.path2 <- "/applications/netlogo 6.0.1" nlstart(nl.path, gui=false, nl.jarname='netlogo-6.0.1.jar') model.path <- "/models/sample models/earth science/fire.nlogo" absolute.model.path <- paste(nl.path2,model.path,sep="") nlloadmodel(absolute.model.path) # fire manual nlcommand("setup") nldocommand(10, "go") burned <- nlreport("burned-trees") print(burned) nlquit()
then gui=true:
sys.setenv(noawt=1) require(jgr) sys.unsetenv("noawt") jgr() # using jgr require(rnetlogo) nl.path <- "/applications/netlogo 6.0.1/java" nl.path2 <- "/applications/netlogo 6.0.1" nlstart(nl.path, gui=true, nl.jarname='netlogo-6.0.1.jar') model.path <- "/models/sample models/earth science/fire.nlogo" absolute.model.path <- paste(nl.path2,model.path,sep="") nlloadmodel(absolute.model.path) # fire manual nlcommand("setup") nldocommand(10, "go") burned <- nlreport("burned-trees") print(burned) nlquit()
Comments
Post a Comment