[R] Silhouette function problem
dwinsemius at comcast.net
Fri Dec 31 18:20:32 CET 2010
On Dec 31, 2010, at 10:34 AM, ADias wrote:
> ADias wrote:
>> I am using the code below to get a plot that will show me on the X
>> 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:
>> I think the problem is on the si.summary.
>> What can I do to solve this problem?
>> thank you
>> A Dias.
> I have made this script
> I need $ avg.width but I don't know how to take that out from the
Do these examples of accessing <something> resembling what you are
asking in that object help?
1 2 3 4 5 6 7
0.3489107 0.2389611 0.2380363 0.3753805 0.6617769 0.4456561 0.3185074
> The mode from avgs is "list" but it does not work as a normal list.
What do you meant when you write "it does not work as a normal list"?
Admittedly it is a name-less list, which seems a bit non-traditional,
but accessing as avgs[] or avgs[] gives appropriate values. (And
_you_ are the one responsible for creating this nameless object.) If
you just look at the beginning of the str results:
List of 20
$ :Classes 'summaryDefault', 'table' Named chr [1:2] "logical" "1"
.. ..- attr(*, "names")= chr [1:2] "Mode" "NA's"
$ :List of 7
..$ si.summary :Classes 'summaryDefault', 'table' Named num
[1:6] -0.435 0.561 0.657 0.516 0.687 ...
.. .. ..- attr(*, "names")= chr [1:6] "Min." "1st Qu." "Median"
<snipped remainder of output>
You can then access the first leaf of the second element:
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.4349 0.5615 0.6574 0.5160 0.6867 0.7525
> Any help would be apreciated.
> 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.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help