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