在 R 中的上三角上使用 hclust

Use hclust on upper triangle in R

我有一个像这样的矩阵:

  a b c
a 1 3 4
b 3 1 2
c 4 2 1

不对角拼接矩阵,可以在上三角上使用hclust吗?

structure(c(1, 3, 4, 3, 1, 2, 4, 2, 1), .Dim = c(3L, 3L), .Dimnames = list(c("a", "b", "c"), c("a", "b", "c")))

有一个强制函数 as.dist,它可以将矩阵转换为 hclust 的正确 class 对象:

> hclust( as.dist( m))

Call:
hclust(d = as.dist(m))

Cluster method   : complete 
Number of objects: 3