Report n patches or turtles randomly selected among agents.

nOf(agents, n)

# S4 method for matrix,numeric
nOf(agents, n)

Arguments

agents Matrix (ncol = 2) with the first column "pxcor" and the second column "pycor" representing the patches coordinates, or 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". Integer. Number of patches or turtles to select from agents.

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".

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".

References

Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.

# Patches
tSelect <- nOf(agents = t1, n = 2)