Skip to contents

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.

Usage

add_named_clusters(
  df,
  clustering,
  method = "CSPA",
  names = c("cluster_1", "cluster_2", "cluster_3"),
  levels = names,
  contrasts = paste0("_", levels),
  base = 1,
  ...
)

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().

Value

A data frame with an additional column cluster that contains the named cluster assignments.