| withMax {NetLogoR} | R Documentation |
Agents with maximum
Description
Report the patches or turtles among agents which have their variable
equals to the maximum value.
Usage
withMax(agents, world, var)
## S4 method for signature 'matrix,worldMatrix,missing'
withMax(agents, world)
## S4 method for signature 'matrix,worldArray,character'
withMax(agents, world, var)
## S4 method for signature 'agentMatrix,missing,character'
withMax(agents, var)
Arguments
agents |
Matrix ( `AgentMatrix` object representing the moving `agents`. |
world |
|
var |
Character. The name of the selected |
Details
world must not be provided if agents are turtles.
Value
Matrix (ncol = 2) with the first column pxcor and the second column
pycor representing the coordinates of the patches among the agents
which have their variable
equal to the maximum value among the agents, or
`AgentMatrix` representing the `turtles` among the `agents`
which have their variable
`var` equal to the maximum value among 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#with-max
Examples
# Patches
w1 <- createWorld(
minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4,
data = sample(1:5, size = 25, replace = TRUE)
)
plot(w1)
p1 <- withMax(agents = patches(w1), world = w1)
# Turtles
t1 <- createTurtles(
n = 10, coords = randomXYcor(w1, n = 10),
heading = sample(1:3, size = 10, replace = TRUE)
)
t2 <- withMax(agents = t1, var = "heading")