我目前正在执行分层集群。我选择使用FactoMineR
由于其良好的数据探索管道:data->MFA->HCPC。
data("wine")
names(wine)
res<-MFA(wine,group = c(2,5,3,10,9,2),type=c("n",rep("s",5)),
ncp=5,name.group = c("orig","olf","vis","olfag","gust","ens"),
num.group.sup = c(1,6))
res.hcpc<-HCPC(res, nb.clust=0, consol=F, iter.max=10, min=3,
max=NULL, metric="euclidean", method="ward", order=TRUE,
graph.scale="sqrt-inertia", nb.par=5, graph=TRUE, proba=0.05,
cluster.CA="rows",kk=Inf)
#Now for some nice plots
plot(res.hcpc,draw.tree = T,choice = "tree")
plot(res.hcpc,draw.tree = T,choice = "bar")
当想要提取答案时,这些已经足够了,但我希望展示这些树。也就是说,我希望通过library(ape)
将它们打扮得漂漂亮亮的。 -examples
问题是这些函数需要 hclust
目的。我的一个选择是使用 MFA
结果并使用 hclust
功能为:res.hc<-hclust(dist(res$global.pca$ind$coord),method = "ward.D2")
建立一个hclust
对象。
这确实有效,但是我发现HCPC
的信息给出的信息更丰富(并且答案与 hclust 不同)。因此我想与 HCPC
合作对象而不是hclust
,但仍然可以使用 library(ape)
中的功能。 知道如何强制 HCPC
至hclust
?
最佳答案
图书馆(ape)
hcpcTree<-res.hcpc$call$t$tree
apeTree<-as.phylo(hcpcTree)
用于库(统计)
dendextendTree<-as.phylo.dendrogram(hcpcTree)
关于r - 强制 HCPC 对象到 hclust 以使用库(ape),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36334536/