Perform clustering on the rows (usually cases) of a dataset.
Usage
cluster(
x,
algorithm = "KMeans",
config = NULL,
execution_config = setup_FutureExecution(),
outdir = NULL,
verbosity = 1L
)Arguments
- x
Matrix, data.frame, or
ClusterConfigobject: Data to cluster (rows are cases to be clustered), or aClusterConfigrecipe (from setup_ClusterConfig) carrying the data path, algorithm config, and output directory.- algorithm
Character: Clustering algorithm. Not needed when
configis supplied, which names its own; an explicitalgorithmthat disagrees withconfigis an error.- config
ClusteringConfig, optional: Algorithm-specific config from a clusteringsetup_*function. Itsfeaturesselects the columns to cluster on;NULLselects every numeric column ofx, since a clustering backend reads numbers. The returned object's config carries the resolved names.- execution_config
ExecutionConfigobject: Execution settings, e.g. setup_FutureExecution or setup_SerialExecution. A clustering dispatches no work to other processes and no registered algorithm threads, so the fit runs on one thread; the config'sseedseeds it.- outdir
Character, optional: Output directory. If not NULL, the returned
Clusteringobject is saved there as an.rdsfile, alongside a run record (cluster_<algorithm>.record.json) stating what the run resolved. See write_record.- verbosity
Integer: Verbosity level.
Details
See docs.rtemis.org/r for detailed documentation.
Examples
iris_km <- cluster(exc(iris, "Species"), algorithm = "KMeans")#> 2026-10-20 09:07:39
#> ▶
#> [cluster]
#> 2026-10-20 09:07:39
#> Input: 150 cases x 4 features.
#> [summarize_unsupervised]
#> 2026-10-20 09:07:39
#> // CPU | future (mirai_multisession) | 7 workers: algorithm 1 thread
#> [msg_resources]
#> 2026-10-20 09:07:39
#> Clustering with KMeans...
#> [cluster]
#> 2026-10-20 09:07:39
#> Checking unsupervised data...
#>
#> ✔
#> [check_unsupervised_data]
#> 2026-10-20 09:07:39
#> Clustering with KMeans ...
#> [cluster_]
#> 2026-10-20 09:07:39
#> Done in 0.10 seconds.
#> [cluster]