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? Arne Neumann> R.versionplatform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 7.1 year 2003 month 06 day 16
> 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> Arne Neumann > > > R.version > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 1 > minor 7.1 > year 2003 > month 06 > day 16 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo> /r-help >
Arne -
I have carried out exactly your example below, and I
get hc$merge as a matrix with two columns and 15 rows.
Do str(hc) to see a useful representation of the
contents of the returned list. help("hclust") describes
this list in the section "Value:". help("Subscript")
shows the various syntactic forms that will extract one
element from a list, but doesn't say quite as explicitly
as one might wish that hc[["merge"]] or hc[[1]] is
the way to return just element "merge" from the list.
Brian Ripley may correct me if I am wrong, but I think
there have never been 'extractor' functions for the
return value from hclust() as there are for lm().
- tom blackwell - u michigan medical school - ann arbor -
On Mon, 3 Nov 2003, Arne Neumann wrote:
> 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?
> Arne Neumann
>
> > R.version
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 1
> minor 7.1
> year 2003
> month 06
> day 16
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>