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_weightandcompet_weightcontains respectively the relative weight of the trait in growth and competition. The function also additionnally check that the traits in thetraitcolumn are in thetraits` data.frame.

check_trait_weights(trait_weights, traits)

Arguments

trait_weights

data.frame with at least three columns equal to trait (giving the name of the concerned traits in traits df), growth_weight the relative weight of the trait in growth and compet_weight the relative weight of the trait in competition.

traits

a species-traits data.frame with species as rownames and traits as numeric columns with names matching trait_weights column trait

Value

nothing if data.frame passes the checks, stops early otherwise.

Examples

# 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)
if (FALSE) {
# 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)
}