| inRadius | R Documentation |
Agents in radiusReport the patches or turtles among agents2 within given distances of
each of the agents. Currently, this function multiplies radius by
1.0000001 so that the response of inRadius is inclusive.
inRadius(agents, radius, agents2, world, torus = FALSE)
## S4 method for signature 'matrix,numeric,matrix'
inRadius(agents, radius, agents2, world, torus = FALSE)
agents |
Matrix ( `AgentMatrix` object representing the moving `agents`. |
radius |
Numeric. Vector of distances from |
agents2 |
Matrix ( `AgentMatrix` object representing the moving `agents`. |
world |
|
torus |
Logical to determine if the |
Distances from/to patches are calculated from/to their center.
If `torus = FALSE`, `world` does not need to be provided.
If `torus = TRUE`, the `radius` distances are calculated
around the sides of the `world` to select `agents2`.
Matrix (ncol = 3) with the first column pxcor
and the second column pycor representing the coordinates of the
patches among agents2 within radius distances for each agents
which are represented by the id column, if
agents2 are patches, or
Matrix (`ncol` = 2) with the first column `who`
representing the `who` numbers of the
`turtles` among `agents2` within `radius` distances for each `agents`
which are represented by the `id` column, if
`agents2` are `turtles`.
Sarah Bauduin
Wilensky, U. 1999. NetLogo. https://www.netlogo.org. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.
https://docs.netlogo.org/dictionary.html#in-radius
w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4)
t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10))
if (requireNamespace("sf", quietly = TRUE)) {
p1 <- inRadius(agents = patch(w1, 0, 0), radius = 2, agents2 = patches(w1))
t2 <- inRadius(agents = patch(w1, 0, 0), radius = 2, agents2 = t1)
p2 <- inRadius(agents = t1, radius = 2, agents2 = patches(w1))
t3 <- inRadius(agents = turtle(t1, who = 0), radius = 2, agents2 = t1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.