【发布时间】:2018-04-04 02:31:14
【问题描述】:
我正在绘制 K-means,如下所示:
library(dplyr)
library(ggfortify)
newdf <- iris %>% group_by(Species) %>% summarise_each(funs(mean))
set.seed(1)
autoplot(kmeans(newdf, 3), data = newdf)
它给我一个错误:
Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning message:
In storage.mode(x) <- "double" : NAs introduced by coercion
【问题讨论】:
-
您将“物种”列传递给
kmeans,而该列是非数字的。没有明显的方法来计算这样一个变量的距离。这是你的意图吗?你到底想在这里发生什么?