scarcity_stack: Scarcity on a stacked data.frame

View source: R/scarcity.R

scarcity_stackR Documentation

Scarcity on a stacked data.frame

Description

Compute scarcity values for several communities. Scarcity computation requires relative abundances. Scarcity is close to 1 when a species is rare in a community and close to 0 when it is abundant. See scarcity() function or the functional rarity indices vignette included in the package (type vignette("rarity_indices", package = "funrar")) for details about the index. You can either use _stack() or _tidy() functions as they are aliases of one another.

Usage

scarcity_stack(com_df, sp_col, com, abund)

scarcity_tidy(com_df, sp_col, com, abund)

Arguments

com_df

a stacked (= tidy) data.frame from a single community with each row representing a species in a community

sp_col

a character vector, the name of the species column in com_df

com

a character vector indicating the column name of communities ID in com_df

abund

a character vector, the name of the column containing relative abundances values

Value

The same table as com_df with an added S_i column for Scarcity values.

See Also

scarcity() and vignette("rarity_indices", package = "funrar") for details on the scarcity metric; distinctiveness_stack(), restrictedness_stack(), uniqueness_stack()

Examples

data("aravo", package = "ade4")

# Site-species matrix converted into data.frame
mat = as.matrix(aravo$spe)
mat = make_relative(mat)
dat = matrix_to_stack(mat, "value", "site", "species")
dat$site = as.character(dat$site)
dat$species = as.character(dat$species)

si_df = scarcity_stack(dat, "species", "site", "value")
head(si_df)


funrar documentation built on Sept. 23, 2022, 5:10 p.m.