leaves: Get leaves values

Description Usage Arguments Value Note Examples

View source: R/mtg_getters_shortcuts.R

Description

Get attribute values from the terminal nodes of the descendants sub-tree of a node (i.e. the "leaves" in computer science terms).

Usage

1
2
3
4
5
6
7
8
leaves(
  attribute,
  node = NULL,
  scale = NULL,
  symbol = NULL,
  link = NULL,
  filter_fun = NULL
)

Arguments

attribute

Any node attribute (as a character)

node

The MTG node

scale

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

symbol

A character vector for filtering the children by the name of their .symbol (i.e. the SYMBOL column from the MTG classes).

link

A character vector for filtering the .link with the children

filter_fun

Any filtering function taking a node as input.

Value

The attribute values from the children of the node

Note

This function is mainly intended to be used with mutate_mtg(). In this case, the node argument can be left empty (or you can put node = node equivalently).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
filepath= system.file("extdata", "simple_plant.mtg", package = "XploRer")
MTG = read_mtg(filepath)

# The MTG has two leaves (node_5 and node_7):
leaves("Length", node = MTG)
# We can check the function worked well by printing the symbols of each nodes:
print(MTG, ".symbol")

# If we need the terminal Internodes:
leaves("Length", node = MTG, symbol = "Internode")

# Or the leaves at a given scale:
print(MTG, ".scale")
leaves("Length", node = MTG, scale = 2)

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