hclust - Hierarchical Clustering in R - 'pvclust' Issues -
i have made reproducible example having trouble pvclust. goal pick ideal clusters in hierarchal cluster dendogram. i've heard of 'pvclust' can't figure out how use it. if has other suggestions besides determine ideal clusters helpful.
my code provided.
library(pvclust) employee<- c('a','b','c','d','e','f','g','h','i', 'j','k','l','m','n','o','p', 'q','r','s','t', 'u','v','w','x','y','z') salary<-c(20,30,40,50,20,40,23,05,56,23,15,43,53,65,67,23,12,14,35,11,10,56,78,23,43,56) testing90<-cbind(employee,salary) testing90<-as.data.frame(testing90) head(testing90) testing90$salary<-as.numeric(testing90$salary) row.names(testing90)<-testing90$employee testing91<-data.frame(testing90[,-1]) head(testing91) row.names(testing91)<-testing90$employee d<-dist(as.matrix(testing91)) hc<-hclust(d,method = "ward.d2") hc plot(hc) par(cex=0.6, mar=c(5, 8, 4, 1)) plot(hc, xlab="", ylab="", main="", sub="", axes=false) par(cex=1) title(xlab="publishers", main="hierarchal cluster of publishers ecpm") axis(2) fit<-pvclust(d, method.hclust="ward.d2", nboot=1000, method.dist="eucl")
an error came stating:
error in names(edges.cnt) <- paste("r", 1:rl, sep = "") : 'names' attribute [2] must same length vector [0]
a solution force object d
matrix
.
from helpfile of pvclust
:
data numeric data matrix or data frame.
note forcing object of type dist
marix, diagonal 'reflected' (math term escapes me right now), can check object being taken account call:
as.matrix(d)
this call looking for:
#note can't pvclust(as.matrix(d), method.hclust="ward.d2", nboot=1000, method.dist="eucl") #bootstrap (r = 0.5)... done. #bootstrap (r = 0.58)... done. #bootstrap (r = 0.69)... done. #bootstrap (r = 0.77)... done. #bootstrap (r = 0.88)... done. #bootstrap (r = 1.0)... done. #bootstrap (r = 1.08)... done. #bootstrap (r = 1.19)... done. #bootstrap (r = 1.27)... done. #bootstrap (r = 1.38)... done. # #cluster method: ward.d2 #distance : euclidean # #estimates on edges: # # au bp se.au se.bp v c pchi #1 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #2 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #3 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #4 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #5 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #6 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #7 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #8 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #9 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #10 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #11 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #12 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #13 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #14 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #15 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #16 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #17 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #18 1.000 1.000 0.000 0.000 0.000 0.000 0.000 #19 0.853 0.885 0.022 0.003 -1.126 -0.076 0.058 #20 0.854 0.885 0.022 0.003 -1.128 -0.073 0.069 #21 0.861 0.897 0.022 0.003 -1.176 -0.090 0.082 #22 0.840 0.886 0.024 0.003 -1.100 -0.106 0.060 #23 0.794 0.690 0.023 0.005 -0.658 0.162 0.591 #24 0.828 0.686 0.020 0.005 -0.716 0.232 0.704 #25 1.000 1.000 0.000 0.000 0.000 0.000 0.000
note method fix call, validity of clustering method, , quality of data decide. mre trusted.
Comments
Post a Comment