Learn R Programming

RNetLogo (version 0.9.2)

NLDoReportWhile: Repeated execution of a command and a reporter in the referenced NetLogo instance while a conditional reporter returns TRUE.

Description

NLDoReportWhile function is used to execute a NetLogo command (submitted as a string) in the submitted NetLogo instance more than one time and to execute the reporter after each iteration. It works like NLDoReport but will be repeated while the conditional reporter returns TRUE.

Usage

NLDoReportWhile(condition, command, reporter, as.data.frame=FALSE, 
                df.col.names=NULL, nl.obj=NULL)

Arguments

condition
A string with a NetLogo conditional reporter.
command
A string with the NetLogo command to be executed.
reporter
A string conataining a NetLogo reporter. (Or a vector/list containing multiple strings with different reporters - but the same effect can be reached via (list var1 var2 var3).)
as.data.frame
(optional) If TRUE the function will return a data.frame instead a list. Default is FALSE which returns a list.
df.col.names
(optional) If as.data.frame=TRUE you can define the names of the columns of the returned data.frame via this parameter. Input should be a vector containing the names as strings in the same order as the submitted reporters.
nl.obj
(optional) A variable holding a reference to a NetLogo instance created with NLStart.

Value

  • A list/nested list with the value(s) of the reporter after each execution of the command.

Details

This function is used to execute a command for more than one time and will report a value or a number of values after each iteration. It is usually used to call a procedure (e.g. "go") while a variable is lower a boundary value and to save the value of a state variable in each simulation step.

See Also

NLDoCommandWhile, NLReport, NLDoReport

Examples

Run this code
nl.path <- "C:/Program Files/NetLogo 4.1.3"
NLStart(nl.path)
model.path <- "/models/Sample Models/Earth Science/Fire.nlogo"
NLLoadModel(paste(nl.path,model.path,sep=""))
NLCommand("setup")
burnedLower2200 <- NLDoReportWhile("burned-trees < 2200", "go", 
                                   "burned-trees")

Run the code above in your browser using DataLab