View source: R/FE_exploratory.R
from.fecoord.to.spcoord | R Documentation |
Convert the data frame of FEs coordinates to a species coordinates one
from.fecoord.to.spcoord(fe_faxes_coord, asb_sp_w, sp_to_fe)
fe_faxes_coord |
the data frame gathering FEs coordinates along functional axes, with columns representing axes and rows representing FEs. |
asb_sp_w |
the data frame gathering species*assemblages, with species in columns and assemblages in rows. |
sp_to_fe |
the output of the mFD::sp.to.fe() function. |
a data frame gathering species coordinates, with axes being columns and species being rows. Note: Works for up to 10 PC.
Camille Magneville
# 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
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.