Hi,

I'm using ade4 R package to perform some clustering operations.
I've got a problem with the representation of my data with rect.hclust

Currently, I do a tree plot, and I'd like to add color boxes on it to show
where the classes are.
As the order of the classes is never the same, I wanted to use the which=
parameter in my rect.hclust.

But here is a huge problem :
Let's say I got 4 classes on my plot.
Default behavior colors my clusters like this : 1-2-3-4 (from left to right)
When I specify which, with which=c(1,2,3,4), same thing again, as expected :
1-2-3-4
With which=c(4,3,2,1), I got : 4-3-2-1 , still ok.
But this becomes way beyhond of my understanding when changing it, like
those
examples :
which=c(1,3,4,2) -> 1-4-2-3 (yes, it's quite strange)
which=c(4,2,1,3) -> 3-2-4-1
and so on

Really, I can't find any reason why it's acting like this, as the doc says :
"which selects clusters by number (from left to right in the tree)"

In fact, I can't even figure out what's the logic behind those quasi-random
orders.
I have to precise that which=c(n1,n2,n3,n4) always give the same order when
relaunched, so, there probably isn't any random thing here afterall.

Any guess ? Any idea how I could, in my script, got my boxes colored in the
right order given in my which parameter ?

Thanks,

Robin Cura

PS : A part of my code :

par(mfrow=c(1,2), oma=c(2,2,2,2))
plot(hang = 0.2,mydata.cah, main="Arbre des classes", xlab="Classes",
ylab="Dissimilarité", sub="" , labels=FALSE )
rect.hclust.nice(cluster=cutree(mydata.cah, k=nbclasses) , mydata.cah,
nbclasses, labels=c(1:nbclasses), density=20, which=c(4,2,1,3))
#rect.hclust(tree=mydata.cah, border=(1:nbclasses), k=nbclasses,
which=c(1,2,3,4) ) # ajout des rectangles de classe sur le graph


(the rect.hclust.nice function is a function I found on the internet, adding
the label and some other things to the usual rect.hclust . Note that I've
got
the same problems with rect.hclust.nice and rect.hclust, they both give the
same box order whith which, and this order is wrong).

	[[alternative HTML version deleted]]

