Get the value of one or several variables from the parent node. This is a helper function that is usually used as input to mutate_mtg() to get the values of the parent node for all nodes.

parent(
  attribute,
  node = NULL,
  scale = NULL,
  symbol = NULL,
  link = NULL,
  filter_fun = NULL,
  continue = TRUE
)

Arguments

attribute

Any node attribute (as a character, an expression or a node callm see details)

node

The node (do not put something when used from mutate_mtg())

scale

An integer vector for filtering the MTG scale of the parent (i.e. the SCALE column from the MTG classes).

symbol

A character vector for filtering the names of the MTG symbol required for the parent (i.e. the SYMBOL column from the MTG classes).

link

A character vector for filtering the .link with the descendant

filter_fun

Any filtering function taking a node as input, e.g. data.tree::isLeaf()

continue

If a parent is not of the right scale, continue until the scale required is met if TRUE, or returns NA if FALSE.

Value

The attribute values from the parent of a node

Details

The attribute argument can be given as a string (e.g. attribute = "Length"), an expression (e.g. attribute = Length) or a call to a node (e.g. attribute = node$Length). All are equivalent because they evaluate the node given by the user or by the calling function. This behavior is set to homogenize the grammar used in the calls of mutate_mtg().

Note

This function returns the values of any attribute of the parent of a node. It is mainly intended to be used in a call to mutate_mtg() (see mutate_mtg() doc for examples).

Examples

filepath= system.file("extdata", "simple_plant.mtg", package = "XploRer") MTG = read_mtg(filepath)
#> Warning: the condition has length > 1 and only the first element will be used
#> Warning: the condition has length > 1 and only the first element will be used
#> Warning: the condition has length > 1 and only the first element will be used
#> Warning: the condition has length > 1 and only the first element will be used
parent(Length, node = extract_node(MTG, "node_5"))
#> node_4 #> 4