View source: R/plot_functions.R
plot_aggregation | R Documentation |
This function plots a tree structure with branches and leaves colored by group memberships. The tree structure can be represented by a variety of object formats: dendrogram
, hclust
or a a list (hc_list
). The aggregation is determined by a vector corresponding to each interior nodes
plot_aggregation(rejections, iflabel = FALSE, labels = NULL, tree = NULL)
rejections |
A vector of length- |
iflabel |
A boolean variable indicating whether leaves should be labeled. |
labels |
A vector of length- |
tree |
An object encoding the tree structure. Can be one of three
formats: (1) an |
## Example 1: Plot an hc object
hc = hclust(dist(USArrests), "ave")
labels = rownames(USArrests)[hc$order]
plot_aggregation(rejections = c(rep(FALSE, 45), rep(TRUE, 4)), iflabel = TRUE, tree = hc)
## Example 2: Plot a dendrogram object
hc = hclust(dist(USArrests), "ave")
dend = as.dendrogram(hc)
plot_aggregation(rejections = c(rep(FALSE, 45), rep(TRUE, 4)), iflabel = TRUE, tree = dend)
## Example 3: Plot a hc_list object
hc = hclust(dist(USArrests), "ave")
dend = as.dendrogram(hc)
dah = dend_as_hclist(dend)
labels = attr(dah, "leaf_labels")
plot_aggregation(rejections = c(rep(FALSE, 45), rep(TRUE, 4)), iflabel = TRUE, labels = labels, tree = dah)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.