R/distinctiveness.R
distinctiveness_stack.Rd
Compute Functional Distinctiveness for several communities, from a stacked
(or tidy) data.frame of communities, with one column for species identity,
one for community identity and an optional one for relative abundances. Also
needs a species functional distances matrix. Functional distinctiveness
relates to the functional "originality" of a species in a community. The
closer to 1 the more the species is functionally distinct from the rest of
the community. See distinctiveness()
function or the
functional rarity indices vignette included in the package
(type vignette("rarity_indices", package = "funrar")
), for more details
on the metric. IMPORTANT NOTE: in order to get functional rarity indices
between 0 and 1, the distance metric has to be scaled between 0 and 1.
You can either use _stack()
or _tidy()
functions as they are aliases of
one another.
distinctiveness_stack(
com_df,
sp_col,
com,
abund = NULL,
dist_matrix,
relative = FALSE
)
distinctiveness_tidy(
com_df,
sp_col,
com,
abund = NULL,
dist_matrix,
relative = FALSE
)
a stacked (= tidy) data.frame from a single community with each row representing a species in a community
a character vector, the name of the species column in com_df
a character vector, the column name for communities names
a character vector, the name of the column containing relative abundances values
a functional distance matrix as given by
compute_dist_matrix()
, with species name as row and column names
a logical indicating if distinctiveness should be scaled relatively to the community (scaled by max functional distance among the species of the targeted community)
the same data.frame with the additional Di column giving functional distinctiveness values for each species
scarcity_stack()
,
uniqueness_stack()
,
restrictedness_stack()
;
distinctiveness()
Details section for detail on the index
data("aravo", package = "ade4")
# Example of trait table
tra = aravo$traits[, c("Height", "SLA", "N_mass")]
# Distance matrix
dist_mat = compute_dist_matrix(tra)
#> Only numeric traits provided, consider using euclidean distance.
# 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)
di_df = distinctiveness_stack(dat, "species", "site", "value", dist_mat)
head(di_df)
#> species site value Di
#> 1 Agro.rupe AR01 0.03125 0.1569403
#> 2 Alop.alpi AR01 0.00000 NA
#> 3 Anth.nipp AR01 0.00000 NA
#> 4 Heli.sede AR01 0.06250 0.1924531
#> 5 Aven.vers AR01 0.00000 NA
#> 6 Care.rosa AR01 0.00000 NA