data("Votes")
### create dummy coding (with removed party affiliation)
x <- as.dummy(Votes[-17])
### calculate distance matrix
d <- dists(x, method = "binary")
### plot dissimilarity matrix unseriated
res <- cluproxplot(d, method = "No seriation",
plotOptions = list(main = "No seriation"))
### plot matrix seriated
res <- cluproxplot(d, plotOptions = list(main = "Seriation - (Murtagh, 1985)"))
### cluster with pam
library("cluster")
l <- pam(d, 8, cluster.only = TRUE)
res <- cluproxplot(d, l, plotOptions = list(main = "PAM + Seriation (Murtagh)"))
### now we use a different seriation algorithm (hclust + optimal leaf ordering)
### and just do the seriation and then use plot to produce the plot
res <- cluproxplot(d, l, method = c("Optimal", "Optimal"), plot = FALSE)
res
### use blue (hue is 260 with decreasing chroma and increasing luminance
### towards a distance of 1)
plot(res, plotOptions = list(main = "PAM + Seriation (Optimal Leaf ordering)",
col = hcl(h = 260, c = seq(75,0, length=5), l = seq(30,95, length=5))))
### the result contains more information, e.g., the order used for reordering
### the matrix
names(res)
res$order
Run the code above in your browser using DataLab