r - 有没有办法从 hclust 获取 "subtree"? (右)

标签 r cluster-analysis

我希望从 hclust 对象创建一个“子树”。

例如,假设我有以下对象:

a <- list()  # initialize empty object
a$merge <- matrix(c(-1, -2,
                    -3, -4,
                     1,  2,
             -5,-6,
             3,4), nc=2, byrow=TRUE ) 
a$height <- c(1, 1.5, 3,4,4.5)    # define merge heights
a$order <- 1:6              # order of leaves(trivial if hand-entered)
a$labels <- 1:6# LETTERS[1:4]    # labels of leaves
class(a) <- "hclust"        # make it an hclust object
plot(a)                     # look at the result   

现在我希望从中提取以下子树:
a <- list()  # initialize empty object
a$merge <- matrix(c(-1, -2,
                    -3, -4,
                     1,  2
                ), nc=2, byrow=TRUE ) 
a$height <- c(1, 1.5, 3)    # define merge heights
a$order <- 1:4             # order of leaves(trivial if hand-entered)
a$labels <- 1:4# LETTERS[1:4]    # labels of leaves
class(a) <- "hclust"        # make it an hclust object
plot(a)                     # look at the result   

我怎么能访问它?

(我知道 cuttree 可以让我获得子树的对象,但不能创建实际的 hclust 对象)

谢谢你的帮助,

塔尔

最佳答案

不确定这是你要找的,但你可以

a <- as.dendrogram(a)
branch1 <- a[[1]]
branch2 <- a[[2]]

par(mfrow=c(1,3))
plot(a)
plot(branch1)
plot(branch2)

关于r - 有没有办法从 hclust 获取 "subtree"? (右),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3033261/

相关文章:

c++ - 用于集群的 C/C++ 机器学习库

hadoop - 使用MapReduce进行聚类的设计

r - geom_line 用于参数函数

c++ - 在 Visual C++ 中使用 C Cluster 库

python - 如何从 Word2Vec 模型中提取向量进行聚类

r - 分离组内不重叠的间隔并在 R 中计数

matplotlib - 为什么Kmeans聚类中同一组簇数据点会落得很远或者很分散?

r - r中的情节标题中的下标

r - 按年和月聚合 POSIX 变量

r - 如何在基本图形图中向轴标签添加美元符号?