绘制K均值

时间:2017-10-23 13:54:00

标签: r k-means

我正在绘制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

1 个答案:

答案 0 :(得分:1)

请将因子的级别更改为“0”,“1”等。取决于因子水平的数量。

然后你可以避免错误