library(sp)
library(maptools)
library(rgdal)
library(spatstat)
library(ggplot2)
library(stats)
install.packages("fpc")
library(fpc)
library(cluster)
install.packages("factoextra")
library(factoextra)
eq<-read.csveq<-read.csv("位置/文件名.csv",header=FALSE,sep=",")
pv1<-data.frame(-1*eq$V5,eq$V6,eq$V11,eq$V12)
pv2<-scale(pv1)
fviz_nbclust(pv2,kmeans,method=”wss”)
+geom_vline(xintercept=6,linetype=2)
ek<-kmeans(pv2,centers=6,iter.max=100)
fviz_cluster(ek,data=pv2)
result<-ek$cluster
centers<-ek$centers
d2<-cbind(eq,type=ek$cluster)
write.csv(centers, "位置/centers.csv")
write.csv(d2,"位置/d2.csv)
- 1
- 2
前往页