NLSetAgentSet: Sets a variable of one or more agent(s) to value(s) in a...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/NLSetAgentSet.R

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

1
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 sort agentset (e.g. turtles are sorted by their who value). If a vector, only one agent variable can be set and the name has to be given by the optional argument var.name.

var.name

If input is a simple vector instead of a data.frame it gives the name of the agent variable as a string which should be set with the values of the vector submitted in input. With a vector you can only set one agent variable at a time.

nl.obj

(optional) A string identifying a reference to a NetLogo instance created with NLStart.

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

1
2
3
4
5
6
7
8
9
## 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)

RNetLogo documentation built on May 2, 2019, 5:54 p.m.