Skip to content

Instantly share code, notes, and snippets.

@smzn
Created January 20, 2017 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smzn/f4eb9606e453f4d8a5170c05a6674e18 to your computer and use it in GitHub Desktop.
Save smzn/f4eb9606e453f4d8a5170c05a6674e18 to your computer and use it in GitHub Desktop.
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