Report `n`

`patches`

or `turtles`

randomly selected among `agents`

.

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

- agents
Matrix (

`ncol`

= 2) with the first column`pxcor`

and the second column`pycor`

representing the`patches`

coordinates, orMatrix (

`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`

, orMatrix (

`ncol`

= 2) with the first column`whoTurtles`

and the second column`id`

.- n
Integer. Number of

`patches`

or`turtles`

to select from`agents`

.

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

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

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

```
# 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)
```