[英]Cluster Analysis using pvclust in R
I want to do cluster analysis of certain columns (variables), say var 5-var10.我想对某些列(变量)进行聚类分析,比如 var 5-var10。 For that I used
pvclust
in R.为此,我在
pvclust
中使用了 pvclust。 Now, I want to add this column of clusters into the actual dataframe.现在,我想将这一列集群添加到实际的 dataframe 中。 Can anybody please help me to fix this problem.
谁能帮我解决这个问题。 The code I used is given below:
我使用的代码如下:
group <- sqldf("select cq14x1_1,cq14x1_2,cq14x1_3,cq14x1_4,cq14x1_5,cq14x1_6,cq14x1_7, from parma_1")
fit_1 <- pvclust(group,method.hclust="ward",method.dist="euclidean")
group_2 <- (fit_1,alpha=.90)
The output of the pvclust
function is an object which contains an hclust
element (check out section Value ). pvclust function 的
pvclust
是一个包含hclust
元素的 object (查看值部分)。 The hclust
is basically a tree representation of the clustering (described here ), and can be fed further into the cutree
function which produces group memeberships. hclust
基本上是聚类的树表示(在此处描述),并且可以进一步输入到产生组成员身份的cutree
function 中。 Have a look at the doc page of cutree
.看看
cutree
的文档页面。 You need these 3 functions to produce actual cluster memberships of your original data which can then be easily added to your dataframe as @nico suggested.您需要这 3 个函数来生成原始数据的实际集群成员资格,然后可以按照@nico 的建议轻松地将其添加到 dataframe 中。
If the problem is adding a column to a dataframe, just use:如果问题是将列添加到 dataframe,只需使用:
yourdataframe <- cbind(yourdataframe, newcolumn)
If that's not your problem, try clarifying the question.如果这不是您的问题,请尝试澄清问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.