# Load Species*Traits dataframe:
data("fruits_traits", package = "mFD")
# Load Assemblages*Species dataframe:
data("baskets_fruits_weights", package = "mFD")
# Load Traits categories dataframe:
data("fruits_traits_cat", package = "mFD")
# Compute functional distance
sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits,
tr_cat = fruits_traits_cat,
metric = "gower",
scale_euclid = "scale_center",
ordinal_var = "classic",
weight_type = "equal",
stop_if_NA = TRUE)
# Compute functional spaces quality to retrieve species coordinates matrix:
fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits,
maxdim_pcoa = 10,
deviation_weighting = "absolute",
fdist_scaling = FALSE,
fdendro = "average")
# Retrieve species coordinates matrix:
sp_faxes_coord_fruits_2D <-
fspaces_quality_fruits$details_fspaces$sp_pc_coord[ , c("PC1", "PC2")]
# Set faxes limits:
# set range of axes if c(NA, NA):
range_sp_coord_fruits <- range(sp_faxes_coord_fruits_2D)
range_faxes_lim <- range_sp_coord_fruits +
c(-1, 1)*(range_sp_coord_fruits[2] -
range_sp_coord_fruits[1]) * 0.05
# Retrieve the background plot:
ggplot_bg_fruits <- mFD::background.plot(
range_faxes = range_faxes_lim,
faxes_nm = c("PC 1", "PC 2"),
color_bg = "grey90")
# Retrieve vertices names:
vert_nm_fruits <- vertices(sp_faxes_coord_fruits_2D,
order_2D = TRUE, check_input = TRUE)
# Plot the pool:
plot_pool_fruits <- pool.plot(ggplot_bg = ggplot_bg_fruits,
sp_coord2D = sp_faxes_coord_fruits_2D,
vertices_nD = vert_nm_fruits,
plot_pool = TRUE,
shape_pool = 3,
size_pool = 0.8,
color_pool = "grey95",
fill_pool = NA,
color_ch = NA,
fill_ch = "white",
alpha_ch = 1,
shape_vert = 3,
size_vert = 1,
color_vert = "black",
fill_vert = NA)
plot_pool_fruits
Run the code above in your browser using DataLab