tests/testthat/test-clustering.R

X <- iris[,1:4]
Dmat <- dist(X)

test_that("complete linkage - data matrix", {
  expect_equal(cutree(hclust(dist(X)),k=3),
               complete.linkage(X,k=3))
})

test_that("clustering results are the same - data matrix", {
  expect_equal(cutree(hclust(dist(X)),k=3),
               clusboot(X,B=2,clustering.func=complete.linkage,k=3)$clustering)
})

complete.dist.wrapper <- function(Dobj, k)
  { cutree(hclust(Dobj), k) }

test_that("clustering results are the same - dist matrix", {
  expect_equal(cutree(hclust(dist(iris[,1:4])),k=3),
               clusboot(Dmat,B=2,clustering.func=complete.dist.wrapper,k=3)$clustering)
})

Try the ClusBoot package in your browser

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

ClusBoot documentation built on Oct. 17, 2023, 5:11 p.m.