How can I get cluster membership as data in kcca method?
I am using kcca
k to match median clustering. I used the following syntax:
kcca.out1_1 <- kcca(clusterdata1_1, k=5, family=kccaFamily("kmedians"), save.data=TRUE)
Now I want the cluster membership to be like a dataframe or vector so that I can use them in my dataset to further analyze the data.
Any help would be much appreciated.
source to share
Try the function clusters
:
clusters(kcca.out1_1)
From the help page:
## S4 method for signature 'flexclust, ANY':
clusters(object, newdata, ...)
clusters
can be used on any class object flexclust
and returns the training data cluster membership.
## S4 method for signature 'kccasimple':
predict(object, newdata, ...)
predict
can only be used for class objects kcca
(which inherit from flexclust
). If no argument newdata
is specified, the function is identical clusters
, if specified newdata
, then the cluster membership for the new data is predicted. clusters(object, newdata, ...)
is an alias for predict(object, newdata, ...)
.
source to share