问题
If we plot a phylogram from hierarchical clustering using ape
package
phy <- hclust(dist(mtcars))
plot(as.phylo(phy),direction="downwards")
Is there a way to extract the labels in to a vector in the same order they appear in the phylogram (read from left to right)?
If I try
phy$labels
I can get the labels out but they appear to be in a different order.
回答1:
Using the additional order
component, you can get them in the proper ordering
with(phy, labels[order])
# [1] "Maserati Bora" "Chrysler Imperial" "Cadillac Fleetwood"
# [4] "Lincoln Continental" "Ford Pantera L" "Duster 360"
# [7] "Camaro Z28" "Hornet Sportabout" "Pontiac Firebird"
# [10] "Hornet 4 Drive" "Valiant" "Merc 450SLC"
# ...
来源:https://stackoverflow.com/questions/31933994/r-phylogram-labels-to-vector