cluster_data.hclust: Extract line segment and label data from hclust object.

Description Usage Arguments Value See Also Examples

Description

Results are stored in a list of data frames containing line segment data and label data.

Usage

1
2
3
  ## S3 method for class 'hclust'
 cluster_data(model, type =
  c("rectangle", "triangle"), ...)

Arguments

model

object of class "hclust", e.g. the output of hclust()

type

The type of plot, indicating the shape of the dendrogram. "rectangle" will draw rectangular lines, while "triangle" will draw triangular lines.

...

ignored

Value

A list with the following elements:

segments

Line segment data

labels

Label data

See Also

cluster_data

Examples

1
2
3
4
5
6
7
8
9
require(ggplot2)
hc <- hclust(dist(USArrests), "ave")
# Rectangular lines
hcdata <- cluster_data(hc, type="rectangle")
ggplot(hcdata$segments) + geom_segment(aes(x=x0, y=y0, xend=x1, yend=y1)) +
coord_flip() + scale_y_reverse(expand=c(0.2, 0))
# Triangular lines
hcdata <- cluster_data(hc, type="triangle")
ggplot(hcdata$segments) + geom_segment(aes(x=x0, y=y0, xend=x1, yend=y1))

pentalibra/ggcluster documentation built on May 25, 2019, 12:46 a.m.