Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

colour_clusters

Colour sub-clusters of a tree (dendrogram/hclust) object


Description

The distinctive feature of this function is to colour both the terminal leaves of a cluster and the edges leading to those leaves. The edgePar attribute of nodes will be augmented by a new list item col. The groups will be defined by a call to slice using the k or h parameters.

Usage

colour_clusters(d, k = NULL, h = NULL, col = rainbow,
  groupLabels = NULL)

color_clusters(d, k = NULL, h = NULL, col = rainbow, groupLabels = NULL)

Arguments

d

A dendrogram or hclust tree object

k

number of groups (passed to slice)

h

height at which to cut tree (passed to slice)

col

Function or vector of colours

groupLabels

If TRUE add numeric group label - see Details for options

Details

If groupLabels=TRUE then numeric group labels will added to each cluster. If a vector is supplied then these entries will be used as the group labels. If a function is supplied then it will be passed a numeric vector of groups (e.g. 1:5) and must return the formatted group labels.

Value

a tree object of class dendrogram.

Author(s)

jefferis

See Also

Examples

d5=colour_clusters(hclust(dist(USArrests), "ave"),5)
plot(d5)
d5g=colour_clusters(hclust(dist(USArrests), "ave"),5,groupLabels=TRUE)
plot(d5g)
d5gr=colour_clusters(hclust(dist(USArrests), "ave"),5,groupLabels=as.roman)
plot(d5gr)

dendroextras

Extra Functions to Cut, Label and Colour Dendrogram Clusters

v0.2.3
GPL (>= 2)
Authors
Gregory Jefferis [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.