| ps_expand | R Documentation |
Takes a matrix or vector computed on occupied sites only and expands it
back to the full site grid, inserting NA for unoccupied sites. This is
useful when performing custom analyses on ps$comm (which contains only
occupied sites) and mapping the results back to the full raster or spatial
object.
ps_expand(ps, x, spatial = FALSE)
ps |
A |
x |
A matrix (or vector) with |
spatial |
Logical: if |
If spatial = FALSE, a matrix with ps$n_sites rows and NA for unoccupied
sites. If spatial = TRUE, a SpatRaster or sf object.
ps <- ps_simulate()
# custom analysis on the occupied-only community matrix
site_totals <- matrix(rowSums(ps$comm), ncol = 1)
colnames(site_totals) <- "total"
# expand to full extent as a matrix
ps_expand(ps, site_totals)
# expand and convert to spatial
ps_expand(ps, site_totals, spatial = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.