From 4d58340c4aa46a0c2fc42f1306289679dd093c09 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Mon, 19 Dec 2022 12:14:14 -0800 Subject: [PATCH] make vignette reactive to close #103 --- vignettes/articles/k_means.Rmd | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vignettes/articles/k_means.Rmd b/vignettes/articles/k_means.Rmd index 0fdd27eb..81af7f97 100644 --- a/vignettes/articles/k_means.Rmd +++ b/vignettes/articles/k_means.Rmd @@ -168,8 +168,17 @@ kmeans_fit %>% extract_centroids() ``` -Based on the above output, we might say that Cluster_1 is penguins with smaller -bill lengths, Cluster_2 has smaller bill depths, and Cluster_3 is penguins with +```{r, echo=FALSE} +centroids <- extract_centroids(kmeans_fit) + +small_length <- centroids$.cluster[which.min(centroids$bill_length_mm)] +small_depth <- centroids$.cluster[which.min(centroids$bill_depth_mm)] +other <- setdiff(levels(centroids$.cluster), c(small_length, small_depth)) +``` + + +Based on the above output, we might say that `r small_length` is penguins with smaller +bill lengths, `r small_depth` has smaller bill depths, and `r other` is penguins with large bills in both dimensions. ## Prediction