I have an abundance of data for 239 species
from 140 sites
. Species are columns
, and sites are rows
.
The matrix looks like the simplified one below. I want to sample from each site 5 individuals without replacement.
Is there any function that allows me to do this?
matrix <-
structure(c(0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 4L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 1L, 0L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L,
0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 10L, 10L, 5L, 0L, 1L, 0L, 0L, 0L, 0L, 0L),
.Dim = c(6L, 10L), .Dimnames = list(NULL, c("Species1", "Species2", "Species3", "Species4",
"Species5", "Species6", "Species7", "Species8", "Species9", "Species10")))`
I tried the Sample function, but it returns whole abundance species instead of 1 individual from that species and picks five species, even those with value = 0 in a sample.
I need a function that samples in each sample one specimen at a time for each sample till it gets to 5 specimens and then moves to the next sample.
Thanks!