Description Usage Arguments Details Value Examples
Get attribute values from all ancestors (basipetal).
1 2 3 4 5 6 7 8 9 10 11 |
attribute |
Any node attribute (as a character) |
node |
The MTG node |
scale |
Integer vector for filtering ancestors by their |
symbol |
A character vector for filtering the ancestors by their |
link |
A character vector for filtering the |
filter_fun |
Any filtering function taking a node as input, e.g. |
self |
Return the value of the current node ( |
continue |
Boolean. If |
recursivity_level |
The maximum number of recursions allowed (considering filters). E.g. to get the
parent only: |
This function is mainly intended to be used with mutate_mtg()
. In this case,
the node
argument can be left empty (or node = node
equivalently).
The attribute values from the ancestors of the node (from first parent to farther ancestor)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | filepath= system.file("extdata", "simple_plant.mtg", package = "XploRer")
MTG = read_mtg(filepath)
# node_6 has four ancestors:
ancestors("Length", node = extract_node(MTG, "node_6"))
# Two of them have no values for Length
# If the value of node_6 is also needed:
ancestors("Length", node = extract_node(MTG, "node_6"), self = TRUE)
# If we only need the value of the first parent:
ancestors("Length", node = extract_node(MTG, "node_6"), recursivity_level = 1)
# We can filter by symbol if we need to return the values for some symbols only:
ancestors("Width", node = extract_node(MTG, "node_6"), symbol = "Internode")
# The values are only returned for the ancestors with the required symbol
# For example we know that a leaf cannot be an ancestor because it cannot bear anything:
ancestors("Width", node = extract_node(MTG, "node_6"), symbol = "Leaf")
# In this case it returns a length 0 vector.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.