Skip to contents

This function returns the community-weighted mean of provided trait values. It only works with quantitative traits and will warn you otherwise. It will remove species that either have NA values in the site_species input or NA values as their trait.

Usage

fb_cwm(site_species, species_traits)

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.

Value

A data.frame with sites in rows and the following variables:

  • site, the site label,

  • trait, the trait label as provided in species_traits,

  • and cwm, the community-weighted means of quantitative traits values.

Examples

library("funbiogeo")

data("site_species")
data("species_traits")

site_cwm <- fb_cwm(head(site_species), species_traits)
#> Some species had NA trait values, removing them from CWM computation
head(site_cwm)
#>   site           trait      cwm
#> 1    1 adult_body_mass 31974.15
#> 2    2 adult_body_mass 39911.51
#> 3    3 adult_body_mass 39912.54
#> 4    4 adult_body_mass 39912.54
#> 5    5 adult_body_mass 41389.44
#> 6    6 adult_body_mass 39912.37