
Add a column with named cluster assignments to a data frame
Source:R/clustering_osivq.R
add_named_clusters.Rd
This function is tailored for three clusters. After checking the results of
the clustering procedure with summarise_clustering()
and a graphical
examination, we can choose names for the three clusters manually and input
them into this function to get a meaningful variable to analyse.
Arguments
- df
A data frame with the OSIVQ scores, typically obtained from
get_clean_data()
.- clustering
A clustering object obtained from
cluster_osivq()
.- method
A character string specifying the consensus clustering method to use. Must be "kmodes", "majority", or "CSPA". Default is "CSPA".
- names
A character vector of names for the clusters. Default is
c("cluster_1", "cluster_2", "cluster_3")
.- levels
A character vector of levels for the factor. Default is the same as
names
.- contrasts
A character vector of contrasts for the factor levels.
- base
An integer indicating the base level for the contrasts. Default is 1, which corresponds to the first cluster in
names
.- ...
Additional arguments passed to
add_factor_contrasts()
.