sample {vegsoup} | R Documentation |
Vegsoup*
Objects The methods take a sample of the specified size from the elements of x
using either with or without replacement. Permutations and random subsamples of the input object can be performed with method sample
. Heterogeneity-constrained random samples are obtained with method hcr
.
## S4 method for signature 'Vegsoup' sample(x, size, replace = FALSE, prob = NULL) ## S4 method for signature 'Vegsoup' hcr(x, size, nperm = 1000, fast = FALSE, ...) ## S4 method for signature 'VegsoupPartition' hcr(x, size, nperm = 1000, fast = FALSE, ...)
x |
|
size |
non-negative integer giving the number of items to choose. For |
replace |
should sampling be with replacement? |
prob |
vector of probability weights for obtaining the elements of the vector being sampled. |
nperm |
the number of permutations. |
fast |
accelerate computations using package |
... |
additional arguments |
See sample
for details. If replace = TRUE
and size is missing, all duplicated plots are removed from the sample. Method hcr
returns the most representative subsample of specified size by selecting from nperm
independent subsets the one that has lowest mean dissimilarity and highest variance.
An object of the same class as the input object.
Roland Kaiser, method hcr
is an re-implementation of function hcr
in package vegclust by Miquel De Cáceres that is capable of forking parallel processes.
Lengyel, A., Chytry, M., Tichy, L. (2011). Heterogeneity-constrained random resampling of phytosociological databases. Journal of Vegetation Science 22: 175-183.
hcr
in vegclust, Vegsoup
, seriation
library(vegsoup) data(windsfeld) x <- windsfeld rownames(sample(x)) # order is permuted rownames(sample(x, size = 3)) # 3 random plots # heterogeneity-constrained random samples # Vegsoup method hcr(x, size = 20) # VegsoupPartition method # we use base::sample to obtain 2 random partitions p <- VegsoupPartition(x, clustering = sample(2, nrow(x), replace = TRUE)) pp <- hcr(p, size = min(table(partitioning(p)))) summary(lm(richness(pp, "sa") ~ partitioning(pp))) # compare run times ## Not run: system.time(hcr(windsfeld, size = 20, nperm = 100000, fast = FALSE)) system.time(hcr(windsfeld, size = 20, nperm = 100000, fast = TRUE)) system.time(vegclust::hcr(as.dist(windsfeld), nout = 20, nsampl = 100000)) ## End(Not run)