View source: R/lets_subsetPAMatt.R
| lets.subsetPAMatt | R Documentation |
Subsets an attribute-based presence-absence matrix (PAM) generated by
lets.attrpam by retaining only a selected set of species.
Species not included in names are removed from the PAM, while the
first three columns of the PAM table are always preserved because they store
attribute-space cell metadata. After subsetting, species richness is
recalculated for each attribute-space cell and written back to the associated
raster object.
lets.subsetPAMatt(x, species, remove.cells = TRUE)
x |
A PAM in attribute space produced by
|
species |
A character vector with species names to retain in the PAM. |
remove.cells |
Logical. If |
Optionally, attribute-space cells with zero richness after subsetting can be removed from the tabular component of the PAM.
The function assumes that the first three columns of x[[1]] contain
non-species information and therefore always preserves them during
subsetting. Richness is recalculated as the row sum across all retained
species columns.
If none of the supplied species names match the species present in the PAM, the function stops with an error.
A list with the same structure as the input object:
x[[1]]: the subsetted attribute PAM table.
x[[2]]: the attribute-space raster with richness values updated
according to the retained species.
lets.attrpam, lets.plot.attrpam
## Not run:
n <- 2000
Species <- paste0("sp", 1:n)
trait_a <- rnorm(n)
trait_b <- trait_a * 0.2 + rnorm(n)
x <- data.frame(Species, trait_a, trait_b)
pam_att <- lets.attrpam(x, n_bins = 30)
names <- sample(Species, 200)
pam_sub <- lets.subsetPAMatt(pam_att, names)
lets.plot.attrpam(pam_sub)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.