Bug 15706 - cophenetic.dendrogram sometimes makes Labels attribute a matrix, sometimes not
Summary: cophenetic.dendrogram sometimes makes Labels attribute a matrix, sometimes not
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Language (show other bugs)
Version: R 3.0.2
Hardware: Other Other
: P5 trivial
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-03-09 00:19 UTC by Bill Dunlap
Modified: 2014-03-09 13:59 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Dunlap 2014-03-09 00:19:35 UTC
If you have a dendrogram, d, with the same number of leaves on each side of the outermost merge node, attr(cophenetic(d, "Labels") will be a 2-column matrix.  If the dendrogram is not so balanced Labels will be a vector.  The correct elements are in Labels, in the correct order, but I think it should always be a vector.  It is as though it uses unlist(sapply(...)) instead of unlist(lapply(...)) when creating the Labels attribute.

> attr(cophenetic(as.dendrogram(hclust(dist(c(i=1,ii=2,iii=3,v=5,vi=6,vii=7))))), "Labels")
     [,1]  [,2] 
[1,] "iii" "vii"
[2,] "i"   "v"  
[3,] "ii"  "vi" 
> attr(cophenetic(as.dendrogram(hclust(dist(c(i=1,ii=2,iii=3,v=5,vi=6))))), "Labels")
[1] "v"   "vi"  "iii" "i"   "ii"