[R] hclust doesn't return merge details [Solved]

Arne Neumann an980634 at uni-greifswald.de
Tue Nov 4 10:15:47 CET 2003


Thanks to Andy and Thomas,

Reading help(hclust) more carefully would have done it but 
sometimes you do not 
see the wood for the trees...
So hc$merge does exactly what I want.
I have never been aware of  the command str to get the structure of 
an R-object. It 
seems pretty useful to me.

Thanks,
Arne


> -----Original Message-----
> From: Liaw, Andy [mailto:andy_liaw at merck.com] 
> Sent: Monday, November 03, 2003 7:10 PM
> To: 'Arne Neumann'; r-help at stat.math.ethz.ch
> Subject: RE: [R] hclust doesn't return merge details
> 
> 
> > From: Arne Neumann [mailto:an980634 at uni-greifswald.de]
> > 
> >  Dear R-users,
> > 
> > I tried to receive the merge details of a clustering by using the 
> > summary function of hclust. For illustration I use the Longley data as
> 
> > done by Prof Ripley (Wed 11 Apr 2001) d <-
> > dist(longley.y)
> > d <- d/max(d) 
> > hc <- hclust(d, "ave") 
> > 
> > But instead of getting a matrix for $merge I get:
> > >summary(hc)
> > 		Length Class  Mode     
> > merge       30     -none- numeric  
> > height      15     -none- numeric  
> > order       16     -none- numeric  
> > labels       0     -none- NULL     
> > method       1     -none- character
> > call         3     -none- call     
> > dist.method  1     -none- character
> > 
> > Am I missing something?
> 
> I believe so.
> 
> > str(hc)
> List of 7
>  $ merge      : int [1:15, 1:2] -6 -13 -10 -1 -9 -3 -5 -16 -12 8 ...
>  $ height     : num [1:15] 20.1 23.6 27.2 29.2 41.4 ...
>  $ order      : int [1:16] 1 2 3 4 16 13 14 12 15 5 ...
>  $ labels     : chr [1:16] "1947" "1948" "1949" "1950" ...
>  $ method     : chr "average"
>  $ call       : language hclust(d = dist(data.matrix(longley)), method =
> "ave")
>  $ dist.method: chr "euclidean"
>  - attr(*, "class")= chr "hclust"
> 
> so the "merge" component is a n x 2 matrix, whose mode is "numeric".
> 
> Andy
>




More information about the R-help mailing list