tests/testthat/test-4-clusterplots.R

test_that("dendrogram plots", {
  skip_if_not_installed("ggplot2")
  require(ggplot2, quietly = TRUE)
  hc <- hclust(dist(USArrests), "ave")
  hcdata <- dendro_data(hc, type = "rectangle")
  p <- ggplot() +
    geom_segment(data = segment(hcdata), aes(x = x0, y = y0, xend = x1, yend = y1)) +
    geom_text(data = label(hcdata), aes(x = x, y = y, label = text)) +
    coord_flip() +
    scale_y_reverse(expand = c(0.2, 0))
  expect_s3_class(p, "ggplot")
})

Try the ggdendro package in your browser

Any scripts or data that you put into this service are public.

ggdendro documentation built on May 29, 2024, 6:12 a.m.