View source: R/lets_maplizer_attr.R
| lets.maplizer.attr | R Documentation |
Summarizes species attributes (e.g., trait values, description year) within
each attribute-space cell of a presence–absence matrix produced by
lets.attrpam. A summary function is applied across
the attributes of species present in each cell, producing a per-cell attribute
surface and an optional raster for visualization.
lets.maplizer.attr(x, y, z, func = mean, ras = TRUE, weighted = FALSE)
x |
An object returned by |
y |
A numeric vector with species attributes to summarize (one value per
species in |
z |
A character vector of species names corresponding to |
func |
A function to summarize attributes across species within each cell
(e.g., |
ras |
Logical; if |
weighted |
If TRUE, argument func is ignored, and weighted mean is calculated. Weights are attributed to each species according to 1/N cells that the species occur. |
Map species attributes in attribute space
Internally, the function multiplies each species presence column by its attribute
value in y (matched by name via z), sets zeros to NA so that
summary functions ignore absences, applies func across species for each cell,
and rasterizes the resulting per-cell summaries onto the attribute raster template.
Cells with no species remain as NA.
A list with:
Matrix_attr: matrix/data.frame with summarized attribute values
per attribute cell (first columns are the cell ID and the two attribute axes).
Attr_Raster: SpatRaster with the summarized attribute
mapped in attribute space.
Bruno Vilela
lets.attrpam, lets.plot.attrpam,
lets.attrcells
## Not run:
# Simulate a dataset of 2000 species with two traits
n <- 2000
Species <- paste0("sp", 1:n)
trait_a <- rnorm(n)
trait_b <- trait_a * 0.2 + rnorm(n)
df <- data.frame(Species, trait_a, trait_b)
# Build attribute-space PAM
x <- lets.attrpam(df, n_bins = 30)
# Map species-level attribute (here, trait_b) by cell using the mean
res <- lets.maplizer.attr(x, y = trait_b, z = Species)
# Plot attribute raster
lets.plot.attrpam(res)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.