Report the patches
or turtles
among agents
which have their variable
equals to the maximum value.
withMax(agents, world, var)
# S4 method for matrix,worldMatrix,missing
withMax(agents, world)
# S4 method for matrix,worldArray,character
withMax(agents, world, var)
# S4 method for agentMatrix,missing,character
withMax(agents, var)
Matrix (ncol
= 2) with the first column pxcor
and the second
column pycor
representing the patches
coordinates, or
WorldMatrix
or worldArray
object.
Character. The name of the selected agents
variable.
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 layer to use to define the patches
values. If agents
are turtles
, var
is one of
the turtles
' variable and can be equal to xcor
,
ycor
, any of the variables created when turtles
were created,
as well as any variable created using turtlesOwn()
.
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
world
must not be provided if agents
are turtles.
Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.
# 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)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'agents' in selecting a method for function 'withMax': unable to find an inherited method for function 'patches' for signature '"worldMatrix"'
# Turtles
t1 <- createTurtles(
n = 10, coords = randomXYcor(w1, n = 10),
heading = sample(1:3, size = 10, replace = TRUE)
)
t2 <- withMax(agents = t1, var = "heading")