简体   繁体   English

使用多个因素标记 hclust 树状图

[英]Labelling a hclust dendogram using multiple factors

I am doing some hierarchical cluster analyses of some ecological data & I am struggling w/the labels, which are numeric and all but meaningless: dendogram w/meaningless labels我正在对一些生态数据进行一些层次聚类分析,并且我正在努力使用标签,这些标签是数字的,几乎毫无意义:带无意义标签的树状图

Essentially I would like to bind together the two factorial columns in my data to create labels that clarify which data points are what, and I do not understand R's labelling system well enough to understand what I am trying to do.本质上,我想将我的数据中的两个阶乘列绑定在一起,以创建标签来阐明哪些数据点是什么,而且我对 R 的标签系统了解得不够好,无法理解我想要做什么。

If seeing my code will help you understand better, then here it is:如果查看我的代码可以帮助您更好地理解,那么这里是:

nta ##data frame: 32obs, 40 variables - 
    ##$Quadrant factor w/8levels
    ##$Position factor w/4levels
nta.bc ##bray-curtis dissimilarity matrix of data
nta.hclust ##average-linked cluster object of nta.bc

##attempt to plot w/labels
plot(nta.hclust) +
  labels(nta, which = c(nta$Quadrant,nta$Position)) +
  rect.hclust(nta.hclust,k=4)

does anyone have any pointers?有人有任何指示吗?

You should include sample data using dput() so that we can illustrate the answer with a sample of your own data.您应该使用dput()包含示例数据,以便我们可以使用您自己的数据示例来说明答案。 Also provide actual code not comments since the problem may lie in your code.还要提供实际代码而不是注释,因为问题可能出在您的代码中。 Here is an example using the varespec data that is included in package vegan .这是一个使用 package vegan中包含的varespec数据的示例。 The main problem is that you are using ggplot2 syntax with base graphics functions.主要问题是您将ggplot2语法与基本图形功能一起使用。 Did you get error messages that you did not include in your question?您是否收到未包含在问题中的错误消息?

data(varespec)    # Load varspec data set included in vegan
vsp.bc <- vegdist(varespec, method="bray")
vsp.hcl <- hclust(vsp.bc, method="average")
plot(vsp.hcl, labels=paste("Plot", rownames(varespec)))
rect.hclust(vsp.hcl, k=4)

树状图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM