Dear All,
 
I am using Silhouette to estimate the number of clusters in a microarray
dataset.
 
Initially, I used the iris data to test my piece of code as follows:
 
library(cluster)
data(iris)
mydata<-iris[,1:4]
maxk<-15                    # at most 15 clusters
myindex<-rep(0,maxk)  # hold the si values for each k clusters
mdist<-1-cor(t(mydata)) #dissimlarity
mdist<-as.dist(mdist)
for(k in 2:maxk)
{     
 hc<-diana(mdist,diss =TRUE, stand = FALSE)     
 si<-silhouette.default(cutree(as.hclust(hc),k=k),mdist)
 myindex<-summary(si)$avg.width
}
myk<-rev(order(myindex))[1]  #select the number of k clusters with the 
                                           #largest si value
 
I met the following problems:
 
> for(k in 2:maxk)
+ {     
+  hc<-diana(mdist,diss =TRUE, stand = FALSE)     
+  si<-silhouette.default(cutree(as.hclust(hc),k=k),mdist)
+  myindex<-summary(si)$avg.width
+ }
Error in "[<-"(*tmp*, iC, "sil_width", value = s.i) : 
        number of items to replace is not a multiple of replacement length
In addition: Warning messages: 
1: longer object length
        is not a multiple of shorter object length in: b.i - a.i 
2: number of rows of result
        is not a multiple of vector length (arg 2) in: cbind(mmm, as.vector(each)) 

Could any one help me how I can solve the problems???
 
Your kind help is highly appreciated!!
 
ping

 



---------------------------------
Post your free ad now! Yahoo! Canada Personals

        [[alternate HTML version deleted]]

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to