我正在尝试修复代码,但得到警告:kmeans中出现错误:群集中心多于不同的数据点。当我运行它。我该如何解决?我的引用来自R Shiny画廊本身(https://shiny.rstudio.com/gallery/kmeans-example.html),但区别在于我需要将文件上传到其中。
我正在使用3.5.3版本以下的R
res_clusters <- reactive({req(df_kmeans_selected())
req(input$n_clusters)
kmeans(
df_kmeans_selected(),
centers = input$n_clusters
)
})
output$plot1 <- renderPlot({
req(df_kmeans_selected())
req(res_clusters())
palette(c(
"#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
"#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"
))
par(mar = c(5.1, 4.1, 0, 1))
plot(df_kmeans_selected(),
col = res_clusters()$cluster,
pch = 20,
cex = 1
)
points(res_clusters()$centers,
pch = 4,
cex = 1,
lwd = 3
我希望k均值图形可以显示但失败。我向您展示了我来自excel This is my data. total 30 data
的数据