data=iris[,-5] dist.e=dist(data,method='euclidean') model1=hclust(dist.e,method='ward')
#分3类 result=cutree(model1,k=3) mds=cmdscale(dist.e,k=2,eig=T) x = mds$points[,1] y = mds$points[,2] library(ggplot2) p=ggplot(data.frame(x,y),aes(x,y)) p+geom_point(size=3,alpha=0.8, aes(colour=factor(result), shape=iris$Species))
|
请发表评论