【发布时间】:2020-03-23 09:16:11
【问题描述】:
我正在使用 K-mean alg。在R 中以分隔变量。我想在我能够管理的ggplot女巫中绘制结果,
然而,ggplot 和 cluster::clusplot 的结果似乎不同
所以我想问一下我缺少什么:例如,我知道缩放比例不同,但我想知道当使用 clustplot 时所有变量都在边界内,而使用 ggplot 时却不是。
仅仅是因为缩放吗?
那么下面两个结果完全一样吗?
library(cluster)
library(ggfortify)
x <- rbind(matrix(rnorm(2000, sd = 123), ncol = 2),
matrix(rnorm(2000, mean = 800, sd = 123), ncol = 2))
colnames(x) <- c("x", "y")
x <- data.frame(x)
A <- kmeans(x, centers = 3, nstart = 50, iter.max = 500)
cluster::clusplot(cbind(x$x, x$y), A$cluster, color = T, shade = T)
autoplot(kmeans(x, centers = 3, nstart = 50, iter.max = 500), data = x, frame.type = 'norm')
【问题讨论】:
标签: r ggplot2 k-means ggfortify