NLSetAgentSet {RNetLogo} | R Documentation |
Sets a variable of one or more agent(s) to value(s) in a data.frame or vector.
Description
NLSetAgentSet
is an easy way to set the variable value(s) of one or more agent(s) (by specifying the name of the agent or the name of an agentset containing the agents) to the value(s) of a data.frame or vector.
Usage
NLSetAgentSet(agentset, input, var.name=NULL, nl.obj=NULL)
Arguments
agentset |
A string specifying the agent or agentset for which values should be changed. |
input |
A data.frame or vector.
If a data.frame, it must have one column with the corresponding agent variable name for each agent variable to be set and one row for each agent.
The rows have to be sorted in the order NetLogo is processing the agentset with |
var.name |
If |
nl.obj |
(optional) A string identifying a reference to a NetLogo instance created with |
Details
The agent variable values contained as columns in the input data.frame are changed. The columns of the data.frame have to be named exactly like the
agent variable which should get the values. The rows have to be sorted as NetLogo would process the agentset using the sort
reporter.
Value
No return value.
Author(s)
Jan C. Thiele <rnetlogo@gmx.de>
See Also
NLSetPatches
,
NLGetAgentSet
,
NLGetGraph
,
NLDfToList
Examples
## Not run:
nl.path <- "C:/Program Files/NetLogo 6.0/app"
NLStart(nl.path)
# NLLoadModel(...)
ag <- NLGetAgentSet(c("xcor","ycor"),"turtles")
ag2 <- data.frame(xcor=ag$xcor, ycor=ag$xcor)
NLSetAgentSet("turtles", ag2)
## End(Not run)