R Programming
May 14, 2026
Updated 12 hours ago
1 min read
R Programming
CURE (Clustering Using Representatives) algorithm
library(stats)
data_points <- data.frame(
x = c(1,2,3,8,9,10,20,21,22),
y = c(2,1,3,8,9,7,20,21,19)
)
k <- 3
# Distance Matrix
dist_matrix <- dist(data_points)
# Hierarchical Clustering
cure_model <- hclust(dist_matrix)
# Form Clusters
clusters <- cutree(cure_model, k)
print(clusters)
# Plot Clusters
plot(
data_points$x,
data_points$y,
col = clusters,
pch = 19,
cex = 2,
main = "CURE Clustering"
)
legend(
"topleft",
legend = paste("Cluster", 1:k),
col = 1:k,
pch = 19
)