nOf {NetLogoR} | R Documentation |
N random agents
Description
Report n
patches
or turtles
randomly selected among agents
.
Usage
nOf(agents, n)
## S4 method for signature 'matrix,numeric'
nOf(agents, n)
Arguments
agents |
Matrix ( Matrix (`ncol` = 3) with the first column "`pxcor` and the second column `pycor` representing the `patches` coordinates and the third column `id`, or `AgentMatrix` object representing the moving `agents`, or Matrix (`ncol` = 2) with the first column `whoTurtles` and the second column `id`. |
n |
Integer. Number of |
Details
n
must be less or equal the number of patches
or turtles
in agents
.
If `agents` is a matrix with `ncol` = 3, the selection of `n` random `patches` is done per individual "id". The order of the `patches` coordinates returned follow the order of "id". If `agents` is a matrix (`ncol` = 2) with columns `whoTurtles` and `id`, the selection of `n` random `turtles` (defined by their `whoTurtles`) is done per individual "id". The order of the `who` numbers returned follow the order of "id".
Value
Matrix (ncol
= 2, nrow
= n
) with the first column pxcor
and the second column pycor
representing the coordinates of the
selected patches from agents
, or
Matrix (`ncol` = 2) with the first column `pxcor` and the second column `pycor` representing the coordinates of the selected `patches` from `agents`, `n` per individual "id", or `AgentMatrix` (`nrow` = `n`) representing the `turtles` selected from `agents`, Integer. Vector of `who` numbers for the selected `turtles` from `agents`, `n` per individual "id".
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#n-of
Examples
# Patches
w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4)
pSelect <- nOf(agents = patches(w1), n = 5)
# Turtles
t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10))
tSelect <- nOf(agents = t1, n = 2)
[Package NetLogoR version 1.0.5 Index]