开发者

Cluster Analysis using pvclust in R

开发者 https://www.devze.com 2023-03-12 16:55 出处:网络
I want to do cluster analysis of certain columns (variables), say var 5-var10. For that I used pvclust in R. Now, I want to add this column of clusters into the actual dataframe. Can anybody please he

I want to do cluster analysis of certain columns (variables), say var 5-var10. For that I used pvclust in R. Now, I want to add this column of clusters into the actual 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,alp开发者_StackOverflow社区ha=.90)


If the problem is adding a column to a dataframe, just use:

yourdataframe <- cbind(yourdataframe, newcolumn)

If that's not your problem, try clarifying the question.


The output of the pvclust function is an object which contains an hclust element (check out section Value). 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. Have a look at the doc page of 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消