Description Usage Arguments Details Value Examples
Extract unique identifiers from inner and terminals
nodes of a partynode
object.
1 2 3 4 5 |
obj |
an object of class |
from |
an integer specifying node to start from. |
terminal |
logical specifying if only node identifiers of terminal nodes are returned. |
... |
additional arguments. |
The identifiers of each node are extracted.
A vector of node identifiers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ## a tree as flat list structure
nodelist <- list(
# root node
list(id = 1L, split = partysplit(varid = 4L, breaks = 1.9),
kids = 2:3),
# V4 <= 1.9, terminal node
list(id = 2L),
# V4 > 1.9
list(id = 3L, split = partysplit(varid = 1L, breaks = 1.7),
kids = c(4L, 7L)),
# V1 <= 1.7
list(id = 4L, split = partysplit(varid = 4L, breaks = 4.8),
kids = 5:6),
# V4 <= 4.8, terminal node
list(id = 5L),
# V4 > 4.8, terminal node
list(id = 6L),
# V1 > 1.7, terminal node
list(id = 7L)
)
## convert to a recursive structure
node <- as.partynode(nodelist)
## set up party object
data("iris")
tree <- party(node, data = iris,
fitted = data.frame("(fitted)" =
fitted_node(node, data = iris),
check.names = FALSE))
tree
### ids of all nodes
nodeids(tree)
### ids of all terminal nodes
nodeids(tree, terminal = TRUE)
### ids of terminal nodes in subtree with root [3]
nodeids(tree, from = 3, terminal = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.