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

Coverage functions do not work with a single species #84

Closed Rekyt closed 1 year ago

Rekyt commented 1 year ago

See below:

library("funbiogeo")

fb_get_all_trait_coverages_by_site(
  site_species[, 1:2], species_traits, all_traits = TRUE
)
#> Error in rowSums(site_species[, -1], na.rm = TRUE): 'x' doit être un tableau ayant au moins 2 dimensions

Created on 2023-05-23 with reprex v2.0.2

Rekyt commented 1 year ago

There should have been a discrepancy in the version I had locally installed, because with the current version this is what I get:

library("funbiogeo")

ko = fb_get_all_trait_coverages_by_site(
  site_species[, 1:2], species_traits, all_traits = TRUE
)

ko[1:2, ]
#>   site all_traits adult_body_mass gestation_length litter_size max_longevity
#> 1    1          1               1                1           1             1
#> 2    2          1               1                1           1             1
#>   sexual_maturity_age diet_breadth
#> 1                   1            1
#> 2                   1            1

Created on 2023-05-31 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.2.0 (2022-04-22 ucrt) #> os Windows 10 x64 (build 19045) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate fr_FR.UTF-8 #> ctype fr_FR.UTF-8 #> tz Europe/Berlin #> date 2023-05-31 #> pandoc 3.0.1 @ C:/Users/ke76dimu/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> class 7.3-22 2023-05-03 [1] CRAN (R 4.2.3) #> classInt 0.4-9 2023-02-28 [1] CRAN (R 4.2.3) #> cli 3.6.1 2023-03-23 [1] CRAN (R 4.2.3) #> DBI 1.1.3 2022-06-18 [1] CRAN (R 4.2.0) #> digest 0.6.31 2022-12-11 [1] CRAN (R 4.2.2) #> dplyr 1.1.2 2023-04-20 [1] CRAN (R 4.2.0) #> e1071 1.7-13 2023-02-01 [1] CRAN (R 4.2.3) #> evaluate 0.21 2023-05-05 [1] CRAN (R 4.2.3) #> fansi 1.0.4 2023-01-22 [1] CRAN (R 4.2.0) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.2.3) #> fs 1.6.2 2023-04-25 [1] CRAN (R 4.2.3) #> funbiogeo * 0.0.0.9000 2023-05-31 [1] Github (FRBCesab/funbiogeo@c168aa9) #> generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.0) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0) #> htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.2.2) #> KernSmooth 2.23-21 2023-05-03 [1] CRAN (R 4.2.3) #> knitr 1.42 2023-01-25 [1] CRAN (R 4.2.2) #> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.1) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0) #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.2.3) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.0) #> proxy 0.4-27 2022-06-09 [1] CRAN (R 4.2.0) #> purrr 1.0.1 2023-01-10 [1] CRAN (R 4.2.2) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.2.1) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.2.0) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.2.0) #> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.2.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0) #> Rcpp 1.0.10 2023-01-22 [1] CRAN (R 4.2.0) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.1) #> rlang 1.1.0 2023-03-14 [1] CRAN (R 4.2.3) #> rmarkdown 2.21 2023-03-26 [1] CRAN (R 4.2.3) #> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.1) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0) #> sf 1.0-12 2023-03-19 [1] CRAN (R 4.2.3) #> styler 1.9.1 2023-03-04 [1] CRAN (R 4.2.3) #> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.2.3) #> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.2.1) #> units 0.8-2 2023-04-27 [1] CRAN (R 4.2.3) #> utf8 1.2.3 2023-01-31 [1] CRAN (R 4.2.3) #> vctrs 0.6.2 2023-04-19 [1] CRAN (R 4.2.3) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.0) #> xfun 0.36 2022-12-21 [1] CRAN (R 4.2.2) #> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.2.2) #> #> [1] C:/Users/ke76dimu/Documents/R/R-4.2.0/library #> #> ────────────────────────────────────────────────────────────────────────────── ```

So no visible issues here. For the sake of safety, I'll check the behavior of other fbget*() functions.

Rekyt commented 1 year ago

They all work perfectly fine, so no need to worry about it.