I've been trying to get plot.hclust to work with a hclust object I created and have not had much success. It seems that there is some "hidden" characteristic of a hclust object that I can't see. This is most easily seen in the following example, where plot.hclust works on one object, but when this object is "dumped" and then re-read, plot.hclust no longer works. Is this a scoping problem? Script started on Wed Feb 20 13:17:37 2002 1>@icarus[101]% R R : Copyright 2002, The R Development Core Team Version 1.4.1 (2002-01-30) ......(stuff deleted)
set.seed(103) library(mva) x <- matrix(rnorm(5*2),ncol=2) x.hc <- hclust(dist(x),method='average') plot.hclust(x.hc)
# the above works
dump('x.hc')
source('dumpdata.R')
plot.hclust(x.hc)
Error in plot.hclust(x.hc) : invalid dendrogram input One hypothesis I had was that it might be something like the "call" object that wasn't correctly being re-created by the dump & source, but that doesn't seem to be it. Below, I remove everything except merge, order, and height, and plot.hclust still works on the original object and fails on the dump + source object.
x.hc <- hclust(dist(x),method='average')
x.hc$call <- NULL
x.hc$dist.method <- NULL
x.hc$method <- NULL
x.hc$labels <- NULL
plot.hclust(x.hc)
dump('x.hc')
source('dumpdata.R')
plot.hclust(x.hc)
Error in plot.hclust(x.hc) : invalid dendrogram input
str(x.hc)
List of 3 $ merge : num [1:4, 1:2] -2 -5 -1 -4 -3 1 2 3 $ height: num [1:4] 0.873 1.257 1.633 2.430 $ order : num [1:5] 4 1 5 2 3 - attr(*, "class")= chr "hclust" Any help would be greatly appreciated! Hugh Chipman
-- Hugh Chipman -- Associate Professor, Statistics & Actuarial Science -- -- University of Waterloo, Ontario, Canada -- -- -- -- Visiting Stanford Statistics Department, January-March 2002 -- -- (650) 725 6148 Fax (650) 725-8977 -- -- Department of Statistics, Sequoia Hall, 390 Serra Mall -- -- Stanford University, Stanford, CA 94305-4065 -- -- http://www.stats.uwaterloo.ca/~hachipma/ hachipman at uwaterloo.ca -- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._