Follow Paths to Selected Nodes of a Tree

DESCRIPTION:

Returns a names list where each element contains the splits on the path from the root to the selected nodes.

USAGE:

path.tree(tree, nodes, pretty=0, print.it=T) 

REQUIRED ARGUMENTS:

tree
fitted model object of class tree. This is assumed to be the result of some function that produces an object with the same named components as that returned by the tree function.

OPTIONAL ARGUMENTS:

nodes
an integer vector containing indices (node numbers) of all nodes for which paths are desired. If missing, user selects nodes as described below.
pretty
an integer denoting the extent to which factor levels will be abbreviated in the character strings containing the splits along the path. The default (0) signifies no abbreviation of levels. A NULL signifies using elements of letters to represent the different factor levels.
print.it
Logical. Denotes whether paths will be printed out as nodes are interactively selected. Irrelevant if nodes argument is supplied.

VALUE:

A named (by node) list, each element of which contains all the splits on the path from the root to the specified or selected nodes.

GRAPHICAL INTERACTION:

A dendrogram of tree is expected to be visible on the graphics device, and a graphics input device (eg a mouse) is required. Clicking (the selection button) on a node selects that node. This process may be repeated any number of times. Clicking the exit button will stop the selection process and return the list of paths.

DETAILS:

The function has a required argument as a tree object and a list of nodes as optional arguments. Omitting a list of nodes will cause the function to wait for the user to select nodes from the dendogram. It will return a list, with one component for each node specified or selected. The component contains the sequence of splits leading to that node. In the graphical interation, the individual paths are printed out as nodes are selected.

Note that the last function that path.tree calls is invisible , which suppresses writing the function's output to the screen. To display the output, use the print command or assign the output from path.tree to a temporary object name, and then type that object's name (see the EXAMPLES section).

SEE ALSO:

.

EXAMPLES:

# Use print() to print the result rather than storing it as a temporary object
fit <- tree(kyphosis)
print(path.tree(fit, nodes=3))
$"3":
[1] "root"       "Start>12.5" 

# Print the output by assigning the output to a temporary object name
# and then typing it. 
kyph.tree <- tree(kyphosis) 
path.tree.nodes.3 <- path.tree(kyph.tree, nodes=3)
path.tree.nodes.3
$"3":
[1] "root"       "Start>12.5"