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

- 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`
`pycor` representing the coordinates of the
and the second column `patches` from `agents`, `n` per individual "id", or
selected
`AgentMatrix` (`nrow` = `n`) representing the `turtles`
`agents`,
selected from
`who` numbers for the selected `turtles` from
Integer. Vector of `agents`, `n` per individual "id".
```

`n`

must be less or equal the number of `patches`

or `turtles`

in `agents`

.

```
`agents` is a matrix with `ncol` = 3, the selection of `n`
If `patches` is done per individual "id". The order of the `patches`
random "id".
coordinates returned follow the order of `agents` is a matrix (`ncol` = 2) with columns `whoTurtles` and
If `id`, the selection of `n` random `turtles` (defined by their `whoTurtles`)
"id". The order of the `who` numbers returned
is done per individual "id". follow the order of
```

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