Learn R Programming

funrar (version 1.5.0)

scarcity_stack: 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)

Value

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

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

See Also

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

Examples

Run this code
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)

Run the code above in your browser using DataLab