Calculate Relative Functional Distinctiveness (FD) from Trait Data
fun_dist.Rd
Computes relative functional distinctiveness for species based on multiple traits. Traits are median-centered before computing pairwise Euclidean distances, and FD is calculated as the mean distance of each species to all others.
Arguments
- data_frame
A data frame containing species data with a column of species names.
- trait_columns
Character vector specifying the names of numeric trait columns to use for FD calculation. Must contain at least two traits.
- species_col
Character string specifying the column in
data_frame
that contains species names. Default is"species"
.
Value
A data.frame
with one row per species containing:
species_col
— species name.fun_dist
— functional distinctiveness value.
Details
Functional distinctiveness (FD) for each species is calculated as the mean of its distances to all other species in the dataset. This is a relative measure — a species can be functionally distinct within a subset of species but not necessarily across all species globally.
Examples
# Create a dataframe of maple species with trait data (SLA, height, seed mass)
maple_data <- data.frame(species_name = c("Acer campestre", "Acer monspessulanum", "Acer negundo", "Acer opalus", "Acer platanoides", "Acer pseudoplatanus", "Acer saccharinum"), SLA = c(5, 15, 6, 11, 23.5, 52, 4), height = c(50, 65, 28, 70, 68, 43, 55), seed_mass = c(1.2, 0.57, 2, 8.5, 0.54, 2.3, 1.9))
FD_results <- fun_dist(data_frame = maple_data, trait_columns = c("SLA", "height", "seed_mass"))
#> Error in dplyr::rename(., species_name = !!species_sym): Can't rename columns that don't exist.
#> ✖ Column `species` doesn't exist.
print(FD_results)
#> Error: object 'FD_results' not found