Error in data.frame(cdatac$id[o], grpcd$cluster[o]) : arguments imply differing number of rows: 0, 239

Hi there
I'm attempt to conduct the clustering analysis. I ran the following code:

## first, clustering on 3 clusters
cdatac <- crfo[,c("STATUS","X1","X2","X3","X4","X5","X6","X7","X8","X9","X10","X11","X12","X13","X14","X15","X16","X17","X18","X19","X20","X21","X22","X23","X24","X25","X26","X27","X28","X29")]
grpcd <- kmeans(cdatac[,-1], centers=3, nstart=10)
grpcd$size
grpcd$centers

## list of cluster assignments
o=order(grpcd$cluster)
data.frame(cdatac$id[o],grpcd$cluster[o])

#In the end I got one error message: 

data.frame(cdatac$id[o],grpcd$cluster[o])
Error in data.frame(cdatac$id[o], grpcd$cluster[o]) : 
  arguments imply differing number of rows: 0, 239

Please let me know where is the problem and how I can fix it. Thanks in advance.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.