R 如何为分布中的每个最大值设置平均线
嗨,我正在R中生成此图,并获得此分布。我在我的数据中估计了4个不同的聚类(使用肘部法),我如何在每个最大值上放置1条红线,而不是您在图中看到的1条红线,并计算考虑到4个不同的分布的加权平均值 My_table2只是一列,其中包含我的距离值R 如何为分布中的每个最大值设置平均线,r,ggplot2,distribution,R,Ggplot2,Distribution,嗨,我正在R中生成此图,并获得此分布。我在我的数据中估计了4个不同的聚类(使用肘部法),我如何在每个最大值上放置1条红线,而不是您在图中看到的1条红线,并计算考虑到4个不同的分布的加权平均值 My_table2只是一列,其中包含我的距离值 ggplot(My_table2, aes(x = Distances)) + geom_histogram(aes(y = ..density..), # the histogram will display "density&qu
ggplot(My_table2, aes(x = Distances)) +
geom_histogram(aes(y = ..density..), # the histogram will display "density" on its y-axis binwidth = 1.9, colour = "blue", fill = "white") +
geom_density(alpha = .5, fill="#FF6655") +
geom_vline(aes(xintercept = mean(Distances, na.rm = T)),
colour = "red", linetype ="longdash", size = .8)+
xlab("distance (nm)")
fviz_nbclust(My_table2, kmeans, method = "wss") +
geom_vline(xintercept = 4, linetype = 2) + visualisation labs(subtitle = "Elbow method")