The leaf function returns the corresponding leaf for each node of the son attribute. The leaf is the very last node of the branch in a directed graph.
leaf(parent, son, group, whichpath, separator, weights, operator)
The attribute containing the parent nodes of a directed graph. The parent parameter is mandatory.
The attribute containing the son nodes of a directed graph. The son parameter is mandatory.
The attribute by which you want to further group results.
The group parameter can also be defined as a list:
When defined, it allows the user to choose which path is to be considered:
If no path is specified, the leaf function applies the “minimum” variable by default.
It specifies the separator to use in the concatenation of different leafs.
The default separator is
This parameter can only be used when the
The attribute defining the length of the edge.
It defines how to combine weights attributes along the path to the leaf.
If left unspecified, the default operator applied is sum and the weight attributes will be summed. While if the operator is prod, they will be multiplied.
It can only be used if the weights parameter is specified.
Example - leaf(parent,son)
The following example uses the Master datadataset.
In this example, we want to retrieve the corresponding leaf for each node.
In the leaf function, we need to define which attribute is the parent, and which is the son.
So, the formula would be:
Here we see the result we have obtained with the leaf function, and we now know what’s the corresponding leaf for each value in the son attribute.