Draws a subsample of the individuals of each population of real data, with the sampling
schemes of sample_individuals(): a fixed number of individuals per population (n), a
share of the individuals (fraction), only the most abundant species of each site
(cover), and a minimum number of individuals per population (min_n). It shows how much a
result depends on sampling effort, alone or through trait_rarefaction().
Usage
subsample_individuals(
individuals,
n = NULL,
fraction = NULL,
cover = NULL,
min_n = 1,
site = "site",
species = "species",
abundance = NULL
)Arguments
- individuals
Data frame with one row per individual.
- n
Number of individuals drawn from each population, or
NULLto keep all.- fraction
Probability that each individual is kept; used when
nisNULL.- cover
Share (0 to 1) of the abundance of each site covered by the species kept, from the most abundant down (Pakeman & Quested 2007), or
NULLto keep every species. Abundances are those of theabundancecolumn, or the numbers of individuals in the data. Species tied in abundance are taken in the order of the data, and populations with an abundance of zero are never kept.- min_n
Minimum number of individuals of a population after sampling.
- site, species
Names of the columns with the site and the species.
- abundance
Name of a column with the abundance of each population (the same value for all its individuals), or
NULLto use the numbers of individuals in the data.
Details
The schemes are applied in this order: species outside cover are removed, individuals are
drawn without replacement (n from each population, all of them when the population is
smaller, or each one with probability fraction), and populations left with fewer than
min_n individuals are removed.
References
Pakeman, R. J., & Quested, H. M. (2007). Sampling plant functional traits: what proportion of the species need to be measured? Applied Vegetation Science, 10, 91–96. doi:10.1111/j.1654-109x.2007.tb00507.x
See also
trait_rarefaction(), sample_individuals().
Other trait variation among individuals:
community_index(),
drift_test(),
neighbour_metrics,
nested_variance(),
null_intervals(),
plot.mc_trait_gradient(),
plot.nested_variance(),
plot.trait_flex(),
plot.trait_rarefaction(),
plot.tstats(),
plot_population_traits(),
population_shifts(),
sample_individuals(),
trait_densities(),
trait_flex(),
trait_gradient(),
trait_gradient_bayes(),
trait_gradient_phylo(),
trait_gradient_test(),
trait_gradient_weights(),
trait_rarefaction(),
tstats(),
tstats_summary()
Examples
set.seed(1)
ind <- data.frame(site = rep(c("s1", "s2"), each = 50),
species = sample(c("a", "b", "c"), 100, TRUE, prob = c(6, 3, 1)),
trait = rnorm(100))
table(subsample_individuals(ind, n = 5)[c("site", "species")])
#> species
#> site a b c
#> s1 5 5 4
#> s2 5 5 2
# only the species making up 80% of the individuals of each site
table(subsample_individuals(ind, cover = 0.8)[c("site", "species")])
#> species
#> site a b
#> s1 27 19
#> s2 30 18
