FRBCesab / funbiogeo

:package: R package to help with analyses in functional biogeography
https://frbcesab.github.io/funbiogeo/
GNU General Public License v2.0
10 stars 1 forks source link

fb_plot_trait_correlation() bugs when a trait is a factor #106

Closed Rekyt closed 7 months ago

Rekyt commented 7 months ago

Bug description

When a factor trait is given to fb_plot_trait_correlation() the function errors and mustn't recognize it as a non-numerical traits. The function should only keep numerical traits.

Reproducible example

# Trait as factor

my_traits = data.frame(
  species = paste0("sp", 1:26),
  trait1 = 1:26,
  trait2 = factor(letters),
  trait3 = LETTERS,
  trait4 = 26:1
)

funbiogeo::fb_plot_trait_correlation(my_traits)
#> Non-numerical traits found, only keeping numerical traits to show trait correlation
#> Error in stats::cor(x[, -1, drop = FALSE], use = "complete.obs", ...): 'x' doit être numérique

funbiogeo::fb_plot_trait_correlation(my_traits[, -3])
#> Non-numerical traits found, only keeping numerical traits to show trait correlation

Created on 2024-04-02 with reprex v2.1.0