| parent.traits | R Documentation |
An internal utility function for modifiers, traits or events to access the value(s) of the parent traits in the treats algorithm
parent.traits(trait.values, lineage, current = TRUE)
trait.values |
The internal table of trait values |
lineage |
The internal lineage data list |
current |
Whether to consider only the current lineage ( |
This function is designed to be used internally in treats to help modifiers, traits or events objects to access the parent traits of the lineages simulated through the internal birth death algorithm.
Returns one or more "numeric" values.
Thomas Guillerme
treats make.modifiers
## Speciation event is more likely if lineage's ancestor is further away from the mean trait value
distance.modify <- function(x, trait.values, lineage) {
## Distance to the parent's trait
parent_trait_val <- parent.traits(trait.values, lineage)[1]
mean_trait_val <- mean(trait.values[, 1])
distance <- abs(parent_trait_val - mean_trait_val)
## Scales x with the distance
return(x + x * distance)
}
## Make a distance modifier (speciation more likely with distance)
distance.speciation <- make.modifiers(speciation = speciation,
modify = distance.modify)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.