2012-04-23 4 views
1

처음으로 R에서 클러스터링을 실험하고 기본 R 도움말 온라인을 살펴본 결과 2 개의 클러스터 솔루션의 결과를 비교하려고했습니다.k-means 클러스터링을 사용하는 2 개의 클러스터 솔루션 비교

관련 데이터 세트의 이름을 먼저 올바르게 지정했지만 이해가되지 않는 오류 메시지가 계속 표시되는지 확인하면서 스크립트를 복사하여 붙여 넣었습니다.

아이디어가 있으십니까?

스크립트는 간단하다 :

2 개 클러스터 솔루션

library(fpc) 
cluster.stats (d, fit1$cluster, fit2$cluster) 

내가 무엇입니까 오류 메시지를 비교하는 것입니다 :

> library(fpc) 
> cluster.stats(d, fit1$cluster, fit2$cluster) 
Error in as.matrix.dist(d) : 
    length of 'dimnames' [1] not equal to array extent 
In addition: Warning messages: 
1: In as.dist.default(d) : NAs introduced by coercion 
2: In as.dist.default(d) : non-square matrix 
3: In as.matrix.dist(d) : 
    number of items to replace is not a multiple of replacement length 

감사

답변

0

d 개체를 포함해야 거리의 행렬 (일반적으로 대칭 행렬 대각선에 0이 붙음). 에서 R은 거리 행렬을 얻을 수있다.

d <- dist(clustering_result) 
관련 문제