2015-06-02 65 views
1

未色集羣我有這樣的矩陣中R:可以被R

  V1  V2  V3  V4  V5  V6  V7 
[1,] 0.00 212.86 217.82 209.23 210.06 214.49 186.01 
[2,] 199.59  0.00 198.07 201.32 200.82 198.94 188.41 
[3,] 200.30 200.85 0.00 198.82 198.43 198.52 185.04 
[4,] 198.74 203.82 199.70 0.00 201.23 199.99 191.83 
[5,] 199.40 203.14 199.09 202.36 0.00 200.28 192.27 
[6,] 199.65 201681.00 198.86 199.21 199.29 0.00 185.71 
[7,] 198.71 202.35 198.74 201.45 200.52 198.77 0.00 

,我想在庫中使用的聚類結果作爲與函數「clusplot」顏色的PAM算法(簇)運行它。

data=read.table('data') 
library(cluster) 
x= pam(data,2) 
clusplot(x, col= x$clustering) 

,但我得到這個錯誤:

Error in clusplot.default (x$data , x$clustering, diss = FALSE, main = main : 
    argument 5 corresponds to several formal arguments 

謝謝您的幫助

+1

嘗試'clusplot(x,color = TRUE)' –

+0

只有數據周圍的圓被着色;而不是數據:( – yokie

+2

檢查所有參數。請參閱'?clustplot.default'或[here](http://www.inside-r.org/r-doc/cluster/clusplot.default)。 –

回答

0

由於clusplot寫你不能確定什麼col值傳遞給直接plotpoints方式。你得到的錯誤是由於部分匹配造成嘗試做到這一點的歧義。

取而代之,請使用col.p參數爲點着色。

clusplot(x, col.p=c("red","blue")[x$cluster])