CmlMagneville / mFD

:package: A Computation of Functional Spaces and Functional Diversity Indices
https://cmlmagneville.github.io/mFD/
GNU General Public License v2.0
25 stars 5 forks source link

Error in Ops.data.frame(guide_loc, panel_loc) : ‘==’ only defined for equally-sized data frames #40

Closed XuWeiEvo closed 7 months ago

XuWeiEvo commented 7 months ago

Dear Camille Magneville,

I encountered an error when I tried running the example code from 'plot_quality_fspaces.R' below:

# 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")

 # Illustrate the quality of functional spaces:
 mFD::quality.fspaces.plot(
  fspaces_quality            = fspaces_quality_fruits,
  quality_metric             = "mad",
  fspaces_plot               = c("tree_average", "pcoa_2d", "pcoa_3d", 
                              "pcoa_4d", "pcoa_5d"),
  name_file                  = NULL, 
  range_dist                 = NULL, 
  range_dev                  = NULL, 
  range_qdev                 = NULL,
  gradient_deviation         = c(neg = "darkblue", nul = "grey80", 
                                 pos = "darkred"),
  gradient_deviation_quality = c(low ="yellow", high = "red"),
  x_lab                      = "Trait-based distance")

However, I received an error message while attempting to generate the plot by mFD::quality.fspaces.plot. The error message reads, "Error in Ops.data.frame(guide_loc, panel_loc) : ‘==’ only defined for equally-sized data frames", and no plot was generated. Can you please provide me with some suggestions? Thank you very much.

Best regards, Wei XU

CmlMagneville commented 7 months ago

Dear Wei Xu, The problem comes from the patchwork package, you have to update it (it's working on my computer after the update to vers 1.2.0) 📦 Hope it helps, Camille

XuWeiEvo commented 7 months ago

Thank you so much for your help! It works now after I updated the patchwork package.

Wei XU