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) (michael.watson@bbsrc.ac.uk)
Date: Fri 21 May 2004 - 21:51:35 EST


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

Hi Sean

I obviously wasn't cut out for this.

Just to try it out, I tried:

>plot(1:8, 1:8, mar=c(5,4,4,2))

(this is the default according to the help)

All I got was:

"there were twelve warnings"

>warnings()
1: parameter "mar" couldn't be set in high-level plot() function

BUT in the help, the example is given as:

<highlevel plot> (..., <tag> = <value>)

So, I know I must be doing something stupid, but I have no idea what....

Mick

-----Original Message-----
From: Sean Davis [mailto:sdavis2@mail.nih.gov]
Sent: 21 May 2004 12:30
To: michael watson (IAH-C); sundar.dorai-raj@pdf.com
Cc: r-help
Subject: Re: [R] Help with hclust() and plot()

See ?par. It is a long help, but pay particular attention to
par(mar=c(...)). It changes margins on plots.

Sean

On 5/21/04 7:12 AM, "michael watson (IAH-C)"
<michael.watson@bbsrc.ac.uk>
wrote:

> OK, I have it working now
> I just read in my data a little differently and now it works
>
> HOWEVER, now my labels shoot off the end of the plot - so the labels
> are truncated as they hit the edge of the window. This happens for
> both horizontal and vertical dendrograms
>
> I guess this is an argument to plot that I need to set, but which one
> ? :-(
>
> Thanks
>
> Mick
>
> -----Original Message-----
> From: michael watson (IAH-C)
> Sent: 21 May 2004 11:53
> To: sundar.dorai-raj@pdf.com
> Cc: R-Help (E-mail)
> Subject: RE: [R] Help with hclust() and plot()
>
>
> Hi
>
> Thanks again, but it *still* doesn't work! I used the following
> commands:
>
>> eucomplete <- hclust(d = dist(p[, 2:13], method = "euclidean"),
>> method
> = "complete")
>> eucomplete$labels
> [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13"
> "14" "15" [16] "16" "17" "18" "19" "20" "21" "22" "23" "24"
>> eucomplete$labels <- p[,1]
>> eucomplete$labels
> [1] NB Hippo S2_824 ME7 Hippo S2_0 ME7 Hippo S2_949 ME7 Hippo
> S2_952
> [5] ME7 Hippo S2_823 NB Hippo S2_819D ME7 Hippo S2_772D ME7 Hippo
> S2_#003
> [9] NB Hippo S2_818D NB Hippo S2_1 NB Hippo S2_#010 NB Hippo
> S2_775D
> [13] NB Hippo S2_774D NB Hippo S2_#009 NB Hippo S2_950 NB Hippo
> S2_826
> [17] NB Hippo S2_#007 NB Hippo S2_951 ME7 Hippo S2_#004 ME7 Hippo
> S2_820D
> [21] ME7 Hippo S2_#005 ME7 Hippo S2_773D ME7 Hippo S2_#006 ME7 Hippo
> S2_822D 24 Levels: ME7 Hippo S2_#003 ME7 Hippo S2_#004 ... NB Hippo
> S2_951
>> plot(as.dendrogram(eucomplete))
>
> I get a lovely formatted dendrogram but the labels are still numbers
> 1-24! :-(
>
> As can be seen, I have changed eucomplete$labels to be the text I
> want, but the plot command still writes out numbers :-(
>
>> plot(eucomplete)
>
> Does work, and I get the right labels. But I want a dendrogram!
>
> Thanks in advance for your help
>
> Mick
>
>
>
> -----Original Message-----
> From: Sundar Dorai-Raj [mailto:sundar.dorai-raj@PDF.COM]
> Sent: 20 May 2004 19:04
> To: michael watson (IAH-C)
> Cc: R-Help (E-mail)
> Subject: Re: [R] Help with hclust() and plot()
>
>
>
>
> michael watson (IAH-C) wrote:
>
>> Hi
>>
>> Thanks for that! BUT if I use as.dendrogram, I can't use my labels
>> anymore!
>>
>>
>>> 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!
>>
>> Mick
>>
>
> Mick,
> Change the labels in hclust first:
>
> data(USArrests)
> hc <- hclust(dist(USArrests), "ave")
> hc$labels <- 1:50
> dend1 <- as.dendrogram(hc)
> plot(dend1, horiz = TRUE)
>
> --sundar
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


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