fdist
takes a functional trait matrix, and returns an ultrametric distance matrix using the method that best preserves the original (non-ultrametric) distances.
References:
Mouchet, M., Guilhaumon, F., Villéger, S., Mason, N. W., Tomasini, J. A., & Mouillot, D. (2008). Towards a consensus for calculating dendrogram‐based functional diversity indices. Oikos, 117(5), 794-800.
Mérigot, B., Durbec, J. P., & Gaertner, J. C. (2010). On goodness-of-fit measure for dendrogram-based analyses. Ecology, 91(6), 1850-1859.
# Create example dataset
example.data <- matrix(runif(100, 0, 1), nrow = 10, ncol = 10)
# Get distance matrix from example data
example.dist <- dist(example.data)
# Load required libraries
library(FD)
library(clue)
# Run function gow2dis
fdist(example.dist, consensus = TRUE)
# Run on raw trait matrix
fdist(example.data)
# Replace continuous with categorical trait
example.data[, 8] <- sample(letters[1:4], replace = T)
fdist(example.data)