# NOT RUN {
# scaled numeric variables from the olives data
# and 20 k-means solutions
so <- scale(olives[,3:10])
rr <- replicate(20,{
kmeans(so,8)$cluster
})
# par(mfrow=c(3,1))
# initial cluster orders
x <- as.data.frame(cbind(olives[,1:2],rr))
require(scales)
scpcp(x, sel = "data[,1]",
sel.palette="rgb", col.opt=list(alpha=0.5))
# reordering using steptile.
# optile does not work for the complete table since it has 9*3*2^60 > 3E19 entries
# colors by the first unordered example:
x2 <- steptile(x, k = 4)
scpcp(x2, sel = "match(data[,1],levels(.GlobalEnv$x[,1]))",
sel.palette="rgb", col.opt=list(alpha=0.5))
# additionally reordering the variables ... cmat takes about 20-30 seconds
CM <- cmat(x[,3:22])
require(seriation)
sM <- get_order(seriate(1-CM))
x3 <- steptile(x2[, c(1,2,2+sM,23)], k = 4)
scpcp(x3, sel = "match(data[,1],levels(.GlobalEnv$x[,1]))",
sel.palette="rgb", col.opt=list(alpha=0.5))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab