View source: R/multigen_function.R
check_trait_weights | R Documentation |
This is an internal help function to check the trait weights data.frame
(used in multigen()
). The structure of the given trait weights is fixed:
one column should be named trait`` with the names of the traits in it. The two other columns
growth_weightand
compet_weightcontains respectively the relative weight of the trait in growth and competition. The function also additionnally check that the traits in the
traitcolumn are in the
traits' data.frame.
check_trait_weights(trait_weights, traits)
trait_weights |
data.frame with at least three columns equal to |
traits |
a species-traits data.frame with species as rownames and
traits as numeric columns with names matching
|
nothing if data.frame passes the checks, stops early otherwise.
# Working trait weights data.frame traits = data.frame(trait1 = 1, trait2 = 2, trait3 = 3) weight_1 = data.frame( trait = c("trait1", "trait2", "trait3"), growth_weight = c(0.5, 0.5, 0), compet_weight = c(0, 0.5, 0.5), hierarchy_weight = c(0, 0, 0)) # Silent function check_trait_weights(weight_1, traits) ## Not run: # Not valid trait weights data.frame not_valid = data.frame(trait = c("trait1", "trait2", "trait3"), growth_weight = c(0.5, 0.8, 0), compet_weight = c(0, 0.5, 0.9)) # Stop and error check_trait_weights(not_valid, traits) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.