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))

相关文章:

  • 2021-08-16
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
  • 2022-02-27
  • 2022-12-23
  • 2021-12-13
  • 2021-11-25
猜你喜欢
  • 2021-04-22
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
相关资源
相似解决方案