Aligns and groups observations based on k-means clustering, enabling observation splits by cluster groups.
Usage
align_kmeans(
centers,
...,
data = NULL,
active = NULL,
set_context = deprecated(),
name = deprecated()
)
Arguments
- centers
either the number of clusters, say \(k\), or a set of initial (distinct) cluster centres. If a number, a random set of (distinct) rows in
x
is chosen as the initial centres.- ...
Arguments passed on to
stats::kmeans
iter.max
the maximum number of iterations allowed.
nstart
if
centers
is a number, how many random sets should be chosen?algorithm
character: may be abbreviated. Note that
"Lloyd"
and"Forgy"
are alternative names for one algorithm.trace
logical or integer number, currently only used in the default method (
"Hartigan-Wong"
): if positive (or true), tracing information on the progress of the algorithm is produced. Higher values may produce more tracing information.
- data
A matrix-like object. By default, it inherits from the layout
matrix
.- active
A
active()
object that defines the context settings when added to a layout.- set_context
- name
Axis Alignment for Observations
It is important to note that we consider rows as observations, meaning
vec_size(data)
/NROW(data)
must match the number of observations along the
axis used for alignment (x-axis for a vertical stack layout, y-axis for a
horizontal stack layout).
quad_layout()
/ggheatmap()
: For column annotation, the layoutmatrix
will be transposed before use (ifdata
is a function, it is applied to the transposed matrix), as column annotation uses columns as observations but alignment requires rows.stack_layout()
: The layout matrix is used as is, aligning all plots along a single axis.