RE: [R] Help with hclust() and plot()

About this list Date view Thread view Subject view Author view Attachment view

From: michael watson (IAH-C) (
Date: Fri 21 May 2004 - 02:12:50 EST

Message-id: <8975119BCD0AC5419D61A9CF1A923E9516EE50@iahce2knas1.iah.bbsrc.reserved>


Thanks for that! BUT if I use as.dendrogram, I can't use my labels

>plot(hclust(...etc), labels=p[,1])

Works fine. But:

>plot(as.dendrogram(hclust(...etc)), labels=p[,1])

Gives me errors:

Error in axis(side, at, labels, tick, line, pos, outer, font, vfont,
lty, :
        location and label lengths differ, 6 != 24

I have 24 labels. I have no idea where it gets 6 from!

My 'dendrogram' has '2 branches and 24 members total'.

SOOO, how do I get my dendrogram horizontal, or vertical for that
matter, with useful labels instead of 1,2,3,4,5,etc

Thanks in advance for your help!


-----Original Message-----
From: Sundar Dorai-Raj [mailto:sundar.dorai-raj@PDF.COM]
Sent: 20 May 2004 16:49
To: michael watson (IAH-C)
Cc: R-Help (E-mail)
Subject: Re: [R] Help with hclust() and plot()

michael watson (IAH-C) wrote:
> Hi
> When I use plot(hclust(dist..)...)...) etc to create a dendrogram of a

> hierarchial cluster analysis, I end up with a vertical tree. What do
> I need to do to get a horizontal tree?
> Also, my users are used to seeing trees who's leaves all "end" at the
> same place (eg. Like in minitab). Is this possible in R?
> Thanks
> Mick

   If you use as.dendrogram first then the plot method for dendrograms
has a horizontal option:

hc <- hclust(dist(USArrests), "ave")
dend1 <- as.dendrogram(hc)
plot(dend1, horiz = TRUE)

This also puts the leave at the end.

R version 1.9.0, 2004-05-06
Windows 2000


______________________________________________ mailing list
PLEASE do read the posting guide!

About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:11 EST