Methods for the generics::tidy(), generics::glance() and
generics::augment() generics, which return plain data frames and need
only the generics package to be installed.
Usage
# S3 method for class 'emeans'
tidy(x, ...)
# S3 method for class 'emeans'
glance(x, ...)
# S3 method for class 'emeans'
augment(x, data = NULL, newdata = NULL, ...)Arguments
- x
An
"emeans"object.- ...
Unused.
- data
The data that was clustered, as a data frame or matrix. Used when
newdataisNULL; needs a fit made withkeep_cluster = TRUE.- newdata
Optional new observations, labelled with
predict().
Value
tidy() returns one row per cluster with the center columns,
size, withinss and cluster (a factor). glance() returns one row
with totss, tot.withinss, betweenss, obj (the last pass's
objective), iter, epochs and n_splits; the sums of squares are NA
for a fit made with keep_cluster = FALSE, which also has no withinss
column in tidy(). augment() returns the data with a
.cluster factor column.
Examples
if (requireNamespace("generics", quietly = TRUE)) {
set.seed(1)
x <- data.frame(a = c(rnorm(100), rnorm(100, mean = 4)),
b = c(rnorm(100), rnorm(100, mean = 4)))
fit <- emeans(x, 2, threads = 1)
generics::tidy(fit)
generics::glance(fit)
head(generics::augment(fit, data = x))
}
#> a b .cluster
#> 1 -0.6264538 0.4094018 1
#> 2 0.1836433 1.6888733 1
#> 3 -0.8356286 1.5865884 1
#> 4 1.5952808 -0.3309078 1
#> 5 0.3295078 -2.2852355 1
#> 6 -0.8204684 2.4976616 1