Wednesday, 15 April 2015

r - I did a clusterward analysis - how to add a column with the results to my original data -



r - I did a clusterward analysis - how to add a column with the results to my original data -

i did cluster ward analysis om (optimal matching) distances obtained traminer.

r>library (cluster) r>clusterward<- agnes (test.om,dis=true, method="ward") # test dataset

i chose 6 clusters

r> cluster6<- cutree(clusterward, k=6)

i tried add together cloumn dataset :

r> groups = cutree(clusterward, k=6) r> result = cbind(clusterward, k=6, groups)

and received next error message :

avis dans cbind(clusterward, k = 6, groups) : number of rows of result not multiple of vector length (arg 1)

how can solve problem ??

the problem clusterward not dataset, results of clustering. suppose have data.frame containing info (individual informations) called "mydata", can use:

mydata <- cbind(mydata, groups)

or (if utilize first command)

mydata <- cbind(mydata, cluster6)

please note should utilize diss=true (and not dis=true) in agnes command.

hope helps.

r cluster-analysis traminer

No comments:

Post a Comment