Computes the functional uniqueness from a site-species matrix with the
provided functional distance matrix. Functional Uniqueness represents how
"isolated" is a species in the global species pool, it is the functional
distance to the nearest neighbor of the species of interest (see `Details`

section for the formula). The sites-species matrix should have **sites**
in **rows** and **species** in **columns**, similar to vegan package
defaults.

`uniqueness(pres_matrix, dist_matrix)`

- pres_matrix
a site-species matrix (presence-absence or relative abundances), with sites in rows and species in columns

- dist_matrix
a species functional distance matrix

A data.frame with functional uniqueness values per species, with one
column with provided species column name and the **Ui** column with
functional uniqueness values.

Functional Uniqueness \(U_i\) is computed as follow: $$ U_i = \min(d_{ij}) \forall j, j \neq i, $$ with \(U_i\) the functional uniqueness of species \(i\), and \(d_ij\) the functional distance between species \(i\) and species \(j\)

```
data("aravo", package = "ade4")
# Site-species matrix
mat = as.matrix(aravo$spe)
colnames(mat) = as.character(colnames(mat))
# 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.
ui = uniqueness(mat, dist_mat)
head(ui)
#> species Ui
#> 1 Agro.rupe 0.03635369
#> 2 Alop.alpi 0.03715692
#> 3 Anth.nipp 0.09414051
#> 4 Heli.sede 0.02270997
#> 5 Aven.vers 0.05675178
#> 6 Care.rosa 0.15922932
# Computing uniqueness for each community
com_ui = apply(mat, 1,
function(x, dist_m) {
smaller_com = x[x > 0 & !is.na(x)]
uniqueness(t(as.matrix(smaller_com)), dist_m)
}, dist_m = dist_mat)
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
```