Learn R Programming

diceplot (version 0.2.0)

perform_clustering: Perform Hierarchical Clustering on Category A

Description

Performs hierarchical clustering on category A based on the binary presence of combinations of categories B and C.

Usage

perform_clustering(data, cat_a, cat_b, cat_c)

Value

A vector of category A labels ordered according to the hierarchical clustering.

Arguments

data

A data frame containing the variables.

cat_a

The name of the column representing category A.

cat_b

The name of the column representing category B.

cat_c

The name of the column representing category C.

Examples

Run this code
library(dplyr)
library(tidyr)
library(tibble)
data <- data.frame(
  cat_a = rep(letters[1:5], each = 4),
  cat_b = rep(LETTERS[1:2], times = 10),
  cat_c = sample(c("Var1", "Var2", "Var3"), 20, replace = TRUE)
)
perform_clustering(data, "cat_a", "cat_b", "cat_c")

Run the code above in your browser using DataLab