NLset: Set an 'agents' variable

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

Description

Assign values to the agents for the selected variables.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
NLset(world, turtles, agents, var, val)

## S4 method for signature 'missing,agentMatrix,agentMatrix,character'
NLset(turtles, agents, var, val)

## S4 method for signature 'worldMatrix,missing,matrix,missing'
NLset(world, agents, val)

## S4 method for signature 'worldArray,missing,matrix,character'
NLset(world, agents, var, val)

Arguments

world

WorldMatrix or worldArray object.

turtles

AgentMatrix object representing the moving agents.

agents

Matrix (ncol = 2) with the first column pxcor and the second column pycor representing the patches coordinates, or

AgentMatrix object representing the moving agents.

var

Character. Vector of the names of the selected agents variables. If agents are patches and the world is a worldMatrix object, var must not be provided. If agents are patches and the world is a worldArray object, var is the name of the layers to use to define the patches values. If agents are turtles, var is some of the turtles' variable and can be any of the variables created when turtles were created, as well as any variable created with turtlesOwn().

val

Numeric or character. Vector of length 1 or length NLcount(agents) if length(var) == 1, or

Matrix or Dataframe (ncol = length(var), nrow = NLcount(agents)). Columns must be in the same order as var.

Details

If agents are patches, world must be provided and turtles must not be provided. If agents are turtles, turtles must be provided and world must not be provided.

Value

WorldMatrix or worldArray object with the values val assigned to the patches variables var for the agents, or

AgentMatrix representing the turtles with the values val assigned to the variables var for the agents.

Author(s)

Sarah Bauduin

References

Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.

See Also

https://ccl.northwestern.edu/netlogo/docs/dictionary.html#set

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4)
w1 <- NLset(world = w1, agents = patches(w1), val = 1)
# Set the patch[0,4] to 0
w1 <- NLset(world = w1, agents = patch(w1, 0, 4), val = 0)
of(world = w1, agents = patches(w1))

t1 <- createTurtles(n = 3, world = w1, heading = 0)
# Set the heading of turtle 0 to 180
t2 <- NLset(turtles = t1, agents = turtle(t1, who = 0), var = "heading", val = 180)
of(agents = t2, var = "heading") # c(180, 0, 0)

NetLogoR documentation built on July 10, 2021, 5:06 p.m.