ggdplot {EnsCat} | R Documentation |
Nice plots of hierarchical clustering results via ggdendrogram
Description
This function provides two different plotting options for either a dendro object or an
object that can be coerced to class dendro, using the function ggdendrogram from the
package ggdendro
Usage
ggdplot(hc, lab = NULL, ptype = 1, title = NULL, ...)
Arguments
hc |
Either a dendro object or an object that can be coerced to class dendro using
the |
lab |
A character vector of labels for the leaves of the tree. By default labels in hc are used. |
ptype |
A numeric indicator of the type of plot desired. If |
title |
A character label for the title of the plot. Only used if |
... |
other parameters passed to |
Details
Given either a dendro object or an object that can be coerced to class dendro, this is a
convenience function for plotting. For an object of type dendro, if ptype==1
, the function
executes the equivalent of
ggdendrogram(hcdata, rotate=TRUE, size=2) + labs(title="Dendrogram in ggplot2")
If ptype!=1
, the function executes the equivalent of
ggdendrogram(hcdata, rotate = TRUE, theme_dendro = FALSE)
Objects that are not of class dendro are coerced to class dendro prior to plotting.
Value
A ggplot
object
Examples
library(ggplot2)
hc <- hclust(dist(USArrests), "ave")
p<-ggdplot(hc, ptype=2)