Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
A kmeans
object created by stats::kmeans()
.
Dimension names. Defaults to the names of the variables
in x. Set to NULL to get names x1, x2, ...
.
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in ...
, where they will be ignored. If the misspelled
argument has a default value, the default value will be used.
For example, if you pass conf.lvel = 0.9
, all computation will
proceed using conf.level = 0.95
. Additionally, if you pass
newdata = my_tibble
to an augment()
method that does not
accept a newdata
argument, it will use the default value for
the data
argument.
For examples, see the kmeans vignette.
Other kmeans tidiers:
augment.kmeans()
,
glance.kmeans()
A tibble::tibble()
with columns:
A factor describing the cluster from 1:k.
Number of points assigned to cluster.
The within-cluster sum of squares.
# feel free to ignore the following lines—they allow {broom} to supply
# examples without requiring the model/data-supplying package to be installed.
if (requireNamespace("cluster", quietly = TRUE)) {
if (requireNamespace("modeldata", quietly = TRUE)) {
library(cluster)
library(modeldata)
library(dplyr)
data(hpc_data)
x <- hpc_data[, 2:5]
fit <- pam(x, k = 4)
tidy(fit)
glance(fit)
augment(fit, x)
}
}
#> # A tibble: 4,331 × 5
#> compounds input_fields iterations num_pending .cluster
#> <dbl> <dbl> <dbl> <dbl> <fct>
#> 1 997 137 20 0 1
#> 2 97 103 20 0 1
#> 3 101 75 10 0 1
#> 4 93 76 20 0 1
#> 5 100 82 20 0 1
#> 6 100 82 20 0 1
#> 7 105 88 20 0 1
#> 8 98 95 20 0 1
#> 9 101 91 20 0 1
#> 10 95 92 20 0 1
#> # … with 4,321 more rows