Skip to content

Instantly share code, notes, and snippets.

@smzn

smzn/Cluster.R

Created Jan 20, 2017
Embed
What would you like to do?
Cluster.R
cluster.agnes <- function(name){
cluster.agnes <- agnes(name, stand = T)
plot(cluster.agnes, which = 2, main = "", xlab = "", ylab = "")
}
cluster.diana <- function(name){
cluster.diana <- agnes(name, stand = T)
plot(cluster.diana, which = 2, main = "", xlab = "", ylab = "")
}
cluster.kmeans <- function(name){
cluster.kmeans = kmeans(dist(name), 6)
cluster.kmeans$cluster
cluster.kmeans$size
clusplot(name, cluster.kmeans$cluster, color=TRUE, shade=TRUE, labels=2, lines=0)
}
cluster.hclust <- function(name){
rect.hclust(hclust(dist(name), method="ward.D"), k = 5, border = "red")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.