knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of clust431 is to do k-means clustering and hierarchical clustering.
You can install the released version of clust431 from CRAN with:
install.packages("clust431")
This is a basic example which compares the original kmeans function to the one made for lab 7
library(clust431) library(tidyverse) iris2 <- iris %>% select(Sepal.Length, Sepal.Width) k_means(iris2, 3, PCA = F)
The chunk below is comparing the results of my function from above to the built-in function.
actual <- kmeans(iris2, 3) actual actual$totss - actual$betweenss actual$totss
As we can see, we get the same SSE, clustering vectors, and cluster means. Our function gives SSE straight up, but there is more calculations needed. That being said, the built-in function has much more information.
This is a basic example which compares the actual hier_clust function to the one made for lab 7
iris3 <- iris %>% select(-c(Species)) b = hier_clust(iris3, k=150, method = 'euclidean') head(b, 6) a = hclust(dist(iris3)) head(a$merge, 6)
hier_clust(iris3, k=3, method = "manhattan")
hier_clust(iris3, k=4, method = "euclidean")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.