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

Simpler species-traits completeness plot #112

Closed Rekyt closed 3 months ago

Rekyt commented 6 months ago

Feature description

We could include a plot (ordered by level of missingness) that would be simpler than what've done

library("funbiogeo")
library("dplyr")
#> Warning: le package 'dplyr' a été compilé avec la version R 4.3.2
#> 
#> Attachement du package : 'dplyr'
#> Les objets suivants sont masqués depuis 'package:stats':
#> 
#>     filter, lag
#> Les objets suivants sont masqués depuis 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library("ggplot2")
#> Warning: le package 'ggplot2' a été compilé avec la version R 4.3.3

species_traits %>%
  tidyr::pivot_longer(-species) %>%
  group_by(name) %>%
  summarise(n_non_missing = sum(!is.na(value)),
            n_missing     = sum(is.na(value))) %>%
  tidyr::pivot_longer(-name, names_to = "trait_type", values_to = "trait_value") %>%
  ggplot(aes(trait_value, name, fill = trait_type)) +
  geom_col()

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

Rekyt commented 6 months ago

We could order the bars by proportion missing. What could be a name? fb_plot_trait_missing() with an option to show proportions vs. raw counts.