Open nuno-agostinho opened 8 years ago
Plot convex hulls from given k-means:
library(cluster)
X <- ruspini
pca <- prcomp(ruspini)
pca <- pca$x[ , 1:2]
# Cluster
pamx <- pam(pca, 5)
cluster <- pamx$cluster
# Plot
plot(pca)
for (each in unique(cluster)) {
segment <- pca[cluster == each, ]
hpts <- chull(segment)
polygon(segment[hpts, ], border=each + 1)
}
These clusters could then be used in survival curves and other analyses.
polygon
seriesSee also cluster analysis in R (1 and 2) and cluster validation using cIVALID