Augment a Dendrogram with a Rug

DESCRIPTION:

Augments the bottom of a dendrogram with a high-density plot that shows the average value of the specified variable for observations in each leaf.

USAGE:

rug.tree(tree, var, FUN = mean, ..., screen.arg = <<see below>>) 

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.
var
numeric variable to be plotted as "rug"; can be any of the numeric variables of the data frame from which tree was made, or any numeric vector of the same length.

OPTIONAL ARGUMENTS:

FUN
function to be applied to values of var at each terminal node.
...
additional arguments (if needed) for FUN.
screen.arg
integer denoting the screen to be used for the plotting. By default the active current screen plus 1 (the next one) is used. See split.screen and tree.screens for more details.

VALUE:

invisibly returns the value of FUN(var) for the observations in each leaf.

SIDE EFFECTS:

a high-density plot of FUN(var) lined up under each leaf of the dendrogram. Assumes that tree.screens has been used to divide the graphics window.

DETAILS:

This is currently NOT a method of the rug function.

SEE ALSO:

, , , .

EXAMPLES:

tree.screens() 
z.auto <- tree(Mileage ~ Weight, car.test.frame) 
plot(z.auto) 
rug.tree(z.auto, HP)  #heights show average HP for cars in each leaf node 
zo <- order.tree(z.auto, Mileage)       #reorder leaf nodes based on Mileage 
screen(1)       #clear screen 1 for new plot 
plot(zo) 
text(zo, pretty = T) 
rug.tree(zo, Price)     #graphically assess correlation of Mileage and Price across leaves