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 dendro_data function, i.e. objects of class dendrogram, hclust or tree

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 ptype==1, the plot is rotated by 90 degrees, the theme is blank, and the title is plotted. If ptype!=1, the plot is rotated by 90 degrees, and the background is a grayscale grid.

title

A character label for the title of the plot. Only used if ptype!=1.

...

other parameters passed to geom_text

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)

[Package EnsCat version 1.1 Index]