sun_man 发表于 2023-10-8 13:45 
问题可能出在NbClust函数的参数设置上。具体来说,报错信息中提到了distance="euclidean",这表明在计算距 ...
又出问题了,不知道啥情况,今天新的例子
library(fMultivar)
library(ggplot2)
set.seed(1234)
df <- rnorm2d(1000, rho=.5)
df <- as.data.frame(df)
ggplot(df, aes(x=V1, y=V2)) +
geom_point(alpha=.3) + theme_minimal() +
labs(title="Bivariate Normal Distribution with rho=0.5")
library(NbClust)
library(factoextra)
nc <- NbClust(df, min.nc=2, max.nc=15, method="kmeans")
fviz_nbclust(nc)
最后一行又出问题了,大神帮忙再看看
“Error in if (class(best_nc) == "numeric") print(best_nc) else if (class(best_nc) == :
the condition has length > 1”