Skip to contents

Compute trait coverage for all sites, i.e., the percentage of total abundance/presence of species that have traits data compared to total species. This function assumes that all species provided in the traits dataset have all their traits specified (meaning that all species have either known or NA values reported as their traits). The coverage of each trait separately is returned as well as all traits taken together if wanted.

Usage

fb_get_all_trait_coverages_by_site(
  site_species,
  species_traits,
  all_traits = TRUE
)

Arguments

site_species

a data.frame with sites in rows and species in columns. NOTE: the first column should be named "site" and indicate site names. The other columns should be named according to species names.

species_traits

a data.frame with species in rows and traits as columns. NOTE: The first column should be named "species" and contain species names. The other columns should be named according to trait names.

all_traits

a logical (default = TRUE) which tell if the coverage considering all provided traits should be provided in an additional column all_traits

Value

a data.frame with a column with sites and one column per provided trait giving its coverage (percent species per site, weighted by abundance that have trait data), and, when argument all_traits = TRUE, an additional column named all_traits considering the coverage of all traits taken together.

Examples

site_trait_cov <- fb_get_all_trait_coverages_by_site(
  site_species, species_traits
)

head(site_trait_cov)
#>   site all_traits adult_body_mass gestation_length litter_size max_longevity
#> 1    1  0.7307692       0.9615385        0.8846154   0.9615385     0.8846154
#> 2    2  0.7586207       0.9655172        0.8965517   0.9655172     0.8965517
#> 3    3  0.7586207       0.9655172        0.8965517   0.9655172     0.8620690
#> 4    4  0.7586207       0.9655172        0.8965517   0.9655172     0.8620690
#> 5    5  0.7857143       0.9642857        0.9285714   0.9642857     0.8928571
#> 6    6  0.7586207       0.9655172        0.9310345   0.9655172     0.8965517
#>   sexual_maturity_age diet_breadth
#> 1           0.8846154    0.8076923
#> 2           0.8965517    0.8275862
#> 3           0.8620690    0.8275862
#> 4           0.8620690    0.8275862
#> 5           0.8928571    0.8571429
#> 6           0.8965517    0.8275862