[R] cluster a distance(analogue)-object using agnes(cluster)

Birgitle birgit.lemcke at systbot.uzh.ch
Tue Sep 2 12:02:31 CEST 2008


I try to perform a clustering using an existing dissimilarity matrix that I
calculated using distance (analogue)
I tried two different things. One of them worked and one not and I don`t
understand why.
Here the code:

not working example

library(cluster)
library(analogue)

iris2<-as.data.frame(iris)
str(iris2)
'data.frame':	150 obs. of  5 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1
1 1 1 ...

Test.Gower <- distance(iris2, method ="mixed")
Test.Gower.agnes<-agnes(Test.Gower, diss=T)
Fehler in agnes(Test.Gower, diss = T) : 
  (list) Objekt kann nicht nach 'logical' umgewandelt werden
Error in agnes(Test.Gower, diss=T).
(list) object can`t be transformed to "logical"

working example only numerics used:

library(cluster)
library(analogue)

irisPart<-subset(iris, select= Sepal.Length:Petal.Width)
Dist.Gower <- distance(irisPart, method ="mixed")
AgnesA <- agnes(Dist.Gower, method="average", diss=TRUE) 

Would be great if somebody could help me.
The dataset that I would like to use for the clustering also contains
factors.
and gives me the same Error message as in the not working example.

Thanks in advance

B.






-----
The art of living is more like wrestling than dancing.
(Marcus Aurelius)
-- 
View this message in context: http://www.nabble.com/cluster-a-distance%28analogue%29-object-using-agnes%28cluster%29-tp19267349p19267349.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list