sortOn {NetLogoR} | R Documentation |
Sort agents
Description
Return the agents
sorted according to their value.
Usage
sortOn(agents, world, var)
## S4 method for signature 'matrix,worldMatrix,missing'
sortOn(agents, world)
## S4 method for signature 'matrix,worldArray,character'
sortOn(agents, world, var)
## S4 method for signature 'agentMatrix,missing,character'
sortOn(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
.
The sorting of the `agents` is done in a increasing order.
Value
Matrix (ncol
= 2) with the first column pxcor
and the second column
pycor
representing the coordinates of the patches
sorted according to
their values, if agents
are patches
, or
`AgentMatrix` representing the `turtles` sorted according to their `var` values, if `agents` are `turtles`.
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#sort-on
Examples
# Patches
w1 <- createWorld(
minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4,
data = sample(1:5, size = 25, replace = TRUE)
)
plot(w1)
p1 <- sortOn(agents = patches(w1), world = w1)
# Turtles
t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10))
sortHeadingT1 <- sortOn(agents = t1, var = "heading")
# or
library(quickPlot)
Plot(w1)
Plot(t1, addTo = "w1")