Interface to use and access Wilensky's NetLogo (Wilensky 1999) from R (R Core Team 2014) using either headless (no GUI) or interactive GUI mode. Provides functions to load models, execute commands, and get values from reporters. Mostly analogous to the NetLogo Mathematica Link https://github.com/NetLogo/Mathematica-Link.
|License:||GNU GPL v2|
Start by creating a NetLogo instance by using
NLStart. Then load a model with the function
NLLoadModel and then use commands and reporters to do what you like.
It is possible to use NetLogo 3D. Just set the
is3d argument in
TRUE. This functionality is experimental. All RNetLogo functions should work in NetLogo 3D as they do in conventional 2D NetLogo except
NLSetPatches, which is not implemented to work with NetLogo 3D properly.
NLSetPatchSet delivers a similar functionality usable also with NetLogo 3D but uses a data.frame instead of a matrix.
Note for MAC users: If you want to run RNetLogo in headless mode (without GUI, i.e. setting argument
NLStart) you have to disable AWT before loading the package. Just execute
Sys.setenv(NOAWT=1) before executing
If you want to run RNetLogo in GUI mode you have to start it from the JGR application (see https://cran.r-project.org/package=JGR and the note at http://groups.yahoo.com/group/netlogo-users/message/14817). It can be necessary to run
Sys.setenv(NOAWT=1) before loading the JGR package and run
Sys.unsetenv("NOAWT") before starting JGR via
Note for Linux users: If you want to run RNetLogo in GUI mode you should start RNetLogo from JGR (see https://cran.r-project.org/package=JGR).
Note for Windows 32-bit users: Starting RNetLogo (in GUI mode) on 32-bit Windows (not 64-bit Windows running in 32-bit mode) may fail in R version 2.15.2 and 2.15.3 (see description here: https://stat.ethz.ch/pipermail/r-devel/2013-January/065576.html). The reason could be the increased C stack size in 2.15.2 and 2.15.3. If you execute
Cstack_info() you can see how large the C stack size is. The problem seems to be resolved with 3.0.0.
A workaround is to use R 2.15.1 or 3.x or to start RNetLogo from JGR (see https://cran.r-project.org/package=JGR) or RStudio (see http://www.rstudio.com/).
If you want to increase the Java Heap Space and set other parameters of the Java Virtual Machine (JVM) see notes at
See the tutorial published as Thiele (2014) for an introduction. Example codes for all functions can be found in the folder "examples" in the installation path of the package. For performance notes see the vignette "performanceNotes.pdf" and for an introduction how to run RNetLogo in parallel on multicore computers or clusters/grids see the vignette "parallelProcessing.pdf".
Jan C. Thiele <firstname.lastname@example.org>
For NetLogo see http://ccl.northwestern.edu/netlogo.
For R Extension for NetLogo see http://r-ext.sourceforge.net/.
For Rserve Extension for NetLogo see http://rserve-ext.sourceforge.net/.
The RNetLogo package is analogous to (and inspired by) the NetLogo Mathematica Link https://github.com/NetLogo/Mathematica-Link.
Thiele, J. (2014) R Marries NetLogo: Introduction to the RNetLogo Package. Journal of Statistical Software 58(2) 1-41. http://www.jstatsoft.org/v58/i02/
Thiele, J., Kurth, W., Grimm, V. (2012) RNetLogo: An R Package for Running and Exploring Individual-Based Models Implemented in NetLogo. Methods in Ecology and Evolution 3(3) 480-483.
R Core Team (2014) R: A Language and Environment for Statistical. R Foundation for Statistical Computing.Vienna, Austria. https://www.r-project.org.
Wilensky, U. (1999) NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
## Not run: library(RNetLogo) nl.path <- "C:/Program Files/NetLogo 6.0/app" nl.jarname <- "netlogo-6.0.0.jar" NLStart(nl.path, nl.jarname=nl.jarname) model.path <- "/models/Sample Models/Earth Science/Fire.nlogo" NLLoadModel(paste(nl.path,model.path,sep="")) NLCommand("setup") NLDoCommand(10, "go") burned <- NLReport("burned-trees") print(burned) NLQuit() ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.