# NOT RUN {
# Iris data
data(iris)
# select the columns of variables
x<- iris[,1:4]
N <- nrow(x)
H <- 1000
a <- matrix(NA, H, N)
# Perform H k-means partitions
for (h in 1:H){
a[h,] <- kmeans(x, centers = 3)$cluster
}
# Build the co-association matrix
C <- matrix(1, N,N)
for (i in 1:(N-1)){
for (j in (i+1):N){
C[i,j] <- sum(a[,i]==a[,j])/H
C[j,i] <- C[i,j]
}}
km <- kmeans(x, centers =3)
# Apply three pivotal criteria to the co-association matrix
ris <- piv_sel(C, clusters = km$cluster)
graphics::plot(iris[,1], iris[,2], xlab ="Sepal.Length", ylab= "Sepal.Width",
col = km$cluster)
# Add the pivots chosen by the maxsumdiff criterion
points( x[ris$pivots[,3], 1:2], col = 1:3,
cex =2, pch = 8 )
# }
Run the code above in your browser using DataLab