我写信是为了索取下面的代码
set.seed(4)
x=matrix(rnorm(50*2),ncol=2)
km.out<-kmeans(x,3,nstart=20)
km.out
plot(x, col=(km.out$cluster +1),main='K-Means Clustering Results with K=3', pch=20, cex=2)
我的问题是为什么要放km.out$cluster +1
,为什么是'''+1''',而且情节丰富多彩,是不是默认设置的?
在线性回归或广义线性回归中,通过使用plot
,使用结果只显示图片,没有颜色。