maxNof {NetLogoR} | R Documentation |
N
agents
with maximum
Description
Report the n
patches
or turtles
among agents
which have their variable
among the maximum values.
Usage
maxNof(agents, n, world, var)
## S4 method for signature 'matrix,numeric,worldMatrix,missing'
maxNof(agents, n, world)
## S4 method for signature 'matrix,numeric,worldArray,character'
maxNof(agents, n, world, var)
## S4 method for signature 'agentMatrix,numeric,missing,character'
maxNof(agents, n, var)
Arguments
agents |
Matrix ( `AgentMatrix` object representing the moving `agents`. |
n |
Integer. |
world |
|
var |
Character. The name of the selected |
Details
world
must not be provided if agents
are turtles
.
If there is a tie that would make the number of returned `patches` or `turtles` larger than `n`, it is broken randomly.
Value
Matrix (ncol
= 2, nrow
= n
) with the first column pxcor
and
the second column pycor
representing the coordinates of the n
patches
among the agents
which have their variable values among
the maximum values among the
agents
, or
`AgentMatrix` of length `n` representing the `turtles` among the `agents` which have their `var` values among the maximum values 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#max-n-of
Examples
# Patches
w1 <- createWorld(
minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4,
data = sample(1:10, size = 25, replace = TRUE)
)
plot(w1)
p1 <- maxNof(agents = patches(w1), n = 6, world = w1)
# Turtles
t1 <- createTurtles(
n = 10, coords = randomXYcor(w1, n = 10),
heading = sample(1:5, size = 10, replace = TRUE)
)
t2 <- maxNof(agents = t1, n = 5, var = "heading")