# Example: Euclidean distance heatmap on iris
eucli_dist <- stats::dist(iris[, 1:4])
dbrobust::plot_heatmap(
dist_mat = eucli_dist,
max_n = 10,
group = iris$Species,
stratified_sampling = TRUE,
main_title = "Euclidean Distance Heatmap",
palette = "YlOrRd",
clustering_method = "complete"
)
# Example: GGower distances with small subset
data("Data_HC_contamination", package = "dbrobust")
Data_small <- Data_HC_contamination[1:50, ]
cont_vars <- c("V1", "V2", "V3", "V4")
cat_vars <- c("V5", "V6", "V7")
bin_vars <- c("V8", "V9")
w <- Data_small$w_loop
dist_sq_ggower <- dbrobust::robust_distances(
data = Data_small,
cont_vars = cont_vars,
bin_vars = bin_vars,
cat_vars = cat_vars,
w = w,
alpha = 0.10,
method = "ggower"
)
group_vec <- rep("Normal", nrow(dist_sq_ggower))
group_vec[attr(dist_sq_ggower, "outlier_idx")] <- "Outlier"
group_factor <- factor(group_vec, levels = c("Normal", "Outlier"))
dbrobust::plot_heatmap(
dist_mat = sqrt(dist_sq_ggower),
max_n = 20,
group = group_factor,
main_title = "GGower Heatmap with Outliers",
palette = "YlOrRd",
clustering_method = "complete",
annotation_legend = TRUE,
stratified_sampling = TRUE,
seed = 123
)
Run the code above in your browser using DataLab