[R] Silhouette function problem

ADias diasandre at gmail.com
Fri Dec 31 16:34:13 CET 2010



ADias wrote:
> 
> Hi,
> 
> I am using the code below to get a plot that will show me on the X axis
> the number of clusters and on the Y axis the cluster average widths.
> However I am getting this error:
> 
> Error in summary(silhouette(cutree(d, x), dist(iris[, -5])))$si.summary : 
>   $ operator is invalid for atomic vectors
> 
> the code I am using is:
> 
> avgs<-sapply(1:20,function(x)
> summary(silhouette(cutree(d,x),
> dist(iris[,-5])))$si.summary[4]) 
> 
> I think the problem is on the si.summary.
> 
> What can I do to solve this problem?
> 
> thank you
> 
> Regards,
> A Dias.
> 

Hi,

I have made this script

library(cluster)
d<-hclust(dist(iris[,-5]))
avgs<-sapply(1:20,function(x)
summary(silhouette(cutree(d,x),
dist(iris[,-5]))))
str(avgs)

I need $ avg.width  but I don't know how to take that out from the object
avgs.
The mode from avgs is "list" but it does not work as a normal list.

Any help would be apreciated.

thanks
A. Dias
-- 
View this message in context: http://r.789695.n4.nabble.com/Silhouette-function-problem-tp3169027p3169522.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list