NLwith {NetLogoR} | R Documentation |
Agents
with
Description
Report the patches
or the turtles
among agents
which have their variable
equals to specific values.
Usage
NLwith(agents, world, var, val)
## S4 method for signature 'matrix,worldMatrix,missing'
NLwith(agents, world, val)
## S4 method for signature 'matrix,worldArray,character'
NLwith(agents, world, var, val)
## S4 method for signature 'agentMatrix,missing,character'
NLwith(agents, var, val)
Arguments
agents |
Matrix ( `AgentMatrix` object representing the moving `agents`. |
world |
|
var |
Character. The name of the selected |
val |
Numeric or character. Vector of any length. |
Details
world
must not be provided if agents
are turtles
.
This is equivalent in R to subsetting. `val` can include `NA`.
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
equals to any val
, or
`AgentMatrix` representing the `turtles` among the `agents` which have their variable `var` equals to any `val`.
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
Examples
# Patches
w1 <- createWorld(
minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4,
data = sample(1:5, size = 25, replace = TRUE)
)
plot(w1)
p2 <- NLwith(agents = patches(w1), world = w1, val = 2)
# Turtles
t1 <- createTurtles(
n = 5, coords = randomXYcor(w1, n = 5),
breed = c("sheep", "sheep", "wolf", "sheep", "sheperd")
)
t2 <- NLwith(agents = t1, var = "breed", val = "sheep")
t3 <- NLwith(agents = t1, var = "breed", val = c("sheep", "wolf"))