Skip to contents

Perform clustering on the rows (usually cases) of a dataset.

Usage

cluster(x, algorithm = "KMeans", config = NULL, outdir = NULL, verbosity = 1L)

Arguments

x

Matrix, data.frame, or ClusterConfig object: Data to cluster (rows are cases to be clustered), or a ClusterConfig recipe (from setup_ClusterConfig) carrying the data path, algorithm config, and output directory.

algorithm

Character: Clustering algorithm.

config

List: Algorithm-specific config.

outdir

Character, optional: Output directory. If not NULL, the returned Clustering object is saved there as an .rds file, alongside a run record (cluster_<algorithm>.record.json) stating what the run resolved. See write_record.

verbosity

Integer: Verbosity level.

Value

Clustering object.

Details

See docs.rtemis.org/r for detailed documentation.

Author

EDG

Examples

iris_km <- cluster(exc(iris, "Species"), algorithm = "KMeans")
#> 2026-08-09 13:22:21 
#>
#>  [cluster]
#> 2026-08-09 13:22:21 
#> Input: 150 cases x 4 features.
#>  [summarize_unsupervised]
#> 2026-08-09 13:22:21 
#> Clustering with KMeans...
#>  [cluster]
#> 2026-08-09 13:22:21 
#> Checking unsupervised data...
#>  
#>
#> [check_unsupervised_data]
#> 2026-08-09 13:22:21 
#> Clustering with KMeans ...
#>  [cluster_]
#> 2026-08-09 13:22:21 
#> Done in 0.06 seconds.
#>  [cluster]