Problem with RNetlogo

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with RNetlogo

NetLogo-Users mailing list
I am just trying to test RNetlogo in my macOS Sierra, with R version 3.4.1 and RStudio.
 I am trying the following script:
 

 require(RNetLogo)
 require(tidyverse)
 require(extrafont)
 loadfonts()
 

 # nl.path <- "/Applications/NetLogo 5.3.1"
 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)
 

 When I use the NLLoadModel command I get the following error (I tried with several nlogo files):
 

 Error in .jcall(nl.obj, "V", "loadModel", .jnew("java/lang/String", model.path)) :
 
   RcallMethod: invalid object parameter
 

Reply | Threaded
Open this post in threaded view
|

Re: Problem with RNetlogo

NetLogo-Users mailing list
Using the Fire.nlogo model in macOS Sierra, I found two solutions (see the manual of RNetLogo):
 First, with 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 from manual
     NLCommand("setup")
     NLDoCommand(10, "go")
     burned <- NLReport("burned-trees")
     print(burned)
     NLQuit()
 Then with gui=TRUE:
 

     Sys.setenv(NOAWT=1)
     require(JGR)
     Sys.unsetenv("NOAWT")
     JGR()
     # Now 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 from manual
     NLCommand("setup")
     NLDoCommand(10, "go")
     burned <- NLReport("burned-trees")
     print(burned)
     NLQuit()