R/calcSpeciesAverageInPus.R
calcSpeciesAverageInPus.Rd
This function calculates the average of species values in each planning unit. By default all polygons will be treated as having separate ids.
calcSpeciesAverageInPus(x, ...)
# S3 method for SpatialPolygons
calcSpeciesAverageInPus(x, y, ids = seq_len(terra::nlyr(y)), ...)
# S3 method for SpatialPolygonsDataFrame
calcSpeciesAverageInPus(x, y, ids = seq_len(terra::nlyr(y)), field = NULL, ...)
# S3 method for sf
calcSpeciesAverageInPus(x, y, ids = seq_len(terra::nlyr(y)), field = NULL, ...)
sf::st_as_sf()
object.
not used.
terra::rast()
object.
integer
vector of ids. Defaults to indices of layers in
argument to y
.
integer
index or character
name of column with
planning unit ids. Valid only when x
is a
sf::st_sf()
or sp::SpatialPolygonsDataFrame()
object.
Default behavior is to treat each polygon as a different planning unit.
A base::data.frame()
object.
Although earlier versions of the package had an additional ncores
parameter, this parameter has been deprecated.
# \dontrun{
# simulate data
sim_pus <- sim.pus(225L)
sim_spp <- terra::rast(
lapply(c("uniform", "normal", "bimodal"),
sim.species, n = 1, res = 1, x = sim_pus)
)
# calculate average for 1 species
puvspr1.dat <- calcSpeciesAverageInPus(sim_pus, sim_spp[[1]])
# calculate average for multiple species
puvspr2.dat <- calcSpeciesAverageInPus(sim_pus, sim_spp)
# }