2016-11-22 2 views
0

저는 HOPACH 클러스터링을 사용하고 있습니다 - 최대 n 클러스터 (예 : 최대 3 개의 플롯) 만 시각화 할 수있는 방법이 있습니까? 현재 코드는 모든 클러스터를 시각화합니다.클러스터링 - 가장 큰 n 개의 클러스터를 그려야합니다.

library(cluster) 
library(hopach) 

distance =distancematrix(DNA[1:30],"cosangle") 
hobpach.DNA =hopach(DNA[1:30],dmat=distance) 

labels = c(hobpach.DNA$clustering$labels) 

table(labels, DNA$class) 

#Plots all clusters 

clusplot(DNA[1:30], hobpach.DNA$clustering$labels, main='Cluster Vis', 
    color=TRUE, shade=TRUE, 
    labels=2, lines=0) 

답변

0

clusplot에는이 내용이 없습니다. 그러나 어떤 클러스터가 가장 큰 지 쉽게 알 수 있으며 이들을 clusplot 기능에만 제공 할 수 있습니다.

# find the indicees of the largest clusters 
biggest_indicees <- labels %in% names(sort(table(labels), decreasing = TRUE)[1:3]) 

# plot three largest clusters 
clusplot(df[biggest_indicees, ], labels[biggest_indicees], main = 'Cluster Vis', 
     color = TRUE, shade = TRUE, labels = 2, lines = 0) 
+0

나는 [biggest_indicees] 안양에서 약간의 문제 ... 오류에 봉착 형식 '폐쇄'의 개체가되어 있지 위의 코드에서 언급대로 레이블을 정의나요 –

+0

을 subsettable? label = c (hobpach.DNA $ clustering $ labels)'이 있습니다. – shadow

+0

예, 정확하게 - 온라인으로이 문제를 검색했습니다. –

관련 문제