parent: Get parent value

Description Usage Arguments Details Value Note Examples

View source: R/mtg_getters_shortcuts.R

Description

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.

Usage

1
2
3
4
5
6
7
8
9
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.

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().

Value

The attribute values from the parent of a node

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

1
2
3
filepath= system.file("extdata", "simple_plant.mtg", package = "XploRer")
MTG = read_mtg(filepath)
parent(Length,  node = extract_node(MTG, "node_5"))

VEZY/XploRer documentation built on Oct. 9, 2021, 10:05 p.m.