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