[R] Plotting horizontal dendrograms

From: Charles K. Minns <ken_at_minns.ca>
Date: Mon, 02 Jun 2008 11:33:17 -0400


I am using hclust and plot to produce dendrograms. Using my input data I am able to complete an analysis and obtain a vertical plot. I want to be able to plot the dendrogram horizontally.I am using version 2.6 of R and have updated my packages recently.  

Using the sample script for dendrograms I can produce a horizontal plot using the instruction horiz = TRUE in plot(). When I use the same instruction in my own script I get a warning message that horiz, and horizontal, are not recognized commands in plot. I cannot find any documentation in R on how to change the orientation of plots and general searches for information on this subject. Can someone explain why my script does not work.  

Sample code follows:



# Sample code extracted from the Dendrogram documentation in R #
require(graphics); require(utils)  
hc <- hclust(dist(USArrests), "ave")
(dend1 <- as.dendrogram(hc)) # "print()" method
str(dend1)          # "str()" method

str(dend1, max = 2) # only the first two sub-levels  

op <- par(mfrow= c(2,2), mar = c(5,2,1,4)) plot(dend1, horiz = TRUE)
plot(dend1)

#
# My code
#

x <- read.table("Rclust2.data",header=TRUE)  
m <- data.matrix(x)
d <- as.dist(m)
h <- hclust(d)

plot(h, horiz = TRUE)

The three plot commands execute. Plot 1 is horizontal, plot 2 is vertical and plot 3 is vertical. Plus plot 3
generates the console output:

> #
> # My code
> #
> x <- read.table("Rclust2.data",header=TRUE)
> 
> m <- data.matrix(x)
> d <- as.dist(m)
> h <- hclust(d)
> plot(h, horiz = TRUE)

Warning messages:
1: In plot.hclust(h, horiz = TRUE) : "horiz" is not a graphical parameter
2: In plot.hclust(h, horiz = TRUE) : "horiz" is not a graphical parameter
3: In title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...) :
  "horiz" is not a graphical parameter
 

I would appreciate help solving this problem. Doubtless there is a simple answer.  

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 02 Jun 2008 - 17:31:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 02 Jun 2008 - 19:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive