library(UniversalCVI)
# The data is from Wiroonsri (2024).
x = R1_data[,1:2]
# ---- Kmeans ----
# Compute the CSL index
K.CSL = CSL.IDX(scale(x), kmax = 15, kmin = 2, method = "kmeans", nstart = 100)
print(K.CSL)
# The optimal number of cluster
K.CSL[which.min(K.CSL$CSL),]
# ---- Hierarchical ----
# Average linkage
# Compute the CSL index
H.CSL = CSL.IDX(scale(x), kmax = 15, kmin = 2, method = "hclust_average")
print(H.CSL)
# The optimal number of cluster
H.CSL[which.min(H.CSL$CSL),]
Run the code above in your browser using DataLab