data(Nclus)
cl1 = kmeans(Nclus, 4)
cl1
cl1a = as.kcca(cl1, Nclus)
cl1a
<testonly>stopifnot(all.equal(cl1$cluster, clusters(cl1a)))</testonly>
library("cluster")
cl2 = pam(Nclus, 4)
cl2
cl2a = as.kcca(cl2)
cl2a
## the same
cl2b = as.kcca(cl2, Nclus)
cl2b
<testonly>stopifnot(all.equal(clusters(cl2a), clusters(cl2b)))
stopifnot(all.equal(parameters(cl2a), parameters(cl2b)))</testonly>Run the code above in your browser using DataLab