Convert the data frame of FEs coordinates to a species coordinates one
Source:R/FE_exploratory.R
from.fecoord.to.spcoord.Rd
Convert the data frame of FEs coordinates to a species coordinates one
Value
a data frame gathering species coordinates, with axes being columns and species being rows. Note: Works for up to 10 PC.
Examples
# Load species traits data:
data("fruits_traits", package = "mFD")
# Transform species traits data:
# Only keep the first 4 traits to illustrate FEs:
fruits_traits <- fruits_traits[ , c(1:4)]
# Load trait types data:
data("fruits_traits_cat", package = "mFD")
# Transform the trait types data to only keep traits 1 - 4:
fruits_traits_cat <- fruits_traits_cat[c(1:4), -3]
# Load Assemblages*Species matrix:
data('baskets_fruits_weights', package = 'mFD')
# Gather species into FEs:
## gathering species into FEs (FEs named according to the decreasing...
## ... number of species they gather):
sp_FEs_fruits <- mFD::sp.to.fe(
sp_tr = fruits_traits,
tr_cat = fruits_traits_cat,
fe_nm_type = "fe_rank")
# Compute the functional distance between FEs:
fe_dist_fruits <- mFD::funct.dist(sp_tr = sp_FEs_fruits$fe_tr,
tr_cat = fruits_traits_cat,
metric = "gower",
scale_euclid = "scale_center",
ordinal_var = "classic",
weight_type = "equal",
stop_if_NA = TRUE)
# Compute the quality of functional spaces:
fspaces_quality_fruits <- mFD::quality.fspaces(
sp_dist = fe_dist_fruits,
maxdim_pcoa = 10,
deviation_weighting = "absolute",
fdist_scaling = FALSE,
fdendro = "average")
fspaces_quality_fruits$quality_fspaces
#> mad
#> pcoa_1d 0.15334415
#> pcoa_2d 0.06766273
#> pcoa_3d 0.05468598
#> pcoa_4d 0.06133105
#> pcoa_5d 0.07202144
#> pcoa_6d 0.07567050
#> pcoa_7d 0.07813058
#> pcoa_8d 0.08013256
#> pcoa_9d 0.08145439
#> pcoa_10d 0.08205815
#> tree_average 0.10189380
# Get coordinates of FEs in the 3D space:
fe_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord
fe_faxes_coord_fruits <- fe_faxes_coord_fruits[, 1:3]
# Get the matrix of species coordinates, from the matrix of FEs coordinates:
sp_faxes_coord <- mFD::from.fecoord.to.spcoord(
fe_faxes_coord = fe_faxes_coord_fruits,
asb_sp_w = baskets_fruits_weights,
sp_to_fe = sp_FEs_fruits)