Display a dendrogram as a ggplot2 layer

stat_nested_hclust(
  mapping = NULL,
  data = NULL,
  geom = "segment",
  position = "identity",
  ...,
  inherit.aes = TRUE,
  show.legend = NA
)

StatNestedHclust

Format

An object of class StatNestedHclust (inherits from Stat, ggproto, gg) of length 4.

Arguments

mapping

A mapping created using aes. Must map x OR y to a qualifier.

data

A nested_hclust object

geom

Any geom that takes x, xend, y, and yend. Probably geom_segment is the only one that makes sense.

position

Position adjustment

...

Passed to the the stat/geom (see geom_segment)

inherit.aes

Inherit aesthetics from ggplot()?

show.legend

Show mapped aesthetics in the legend?

Value

A ggplot2::Stat

Examples

library(ggplot2)
library(dplyr, warn.conflicts = FALSE)

alta_coniss <- nested_data(
  alta_lake_geochem,
  qualifiers = c(age, depth, zone),
  key = param,
  value = value,
  trans = scale
) %>%
  nested_chclust_coniss()

ggplot(alta_coniss) +
  stat_nested_hclust(aes(model = model, y = depth)) +
  scale_y_reverse()