r - Assign class to data frame after clustering -
i used k-means cluster algorithm on data-frame df1 , result shown in picture below.
library(ade4) df1 <- data.frame(x=runif(100), y=runif(100)) plot(df1) km <- kmeans(df1, centers=3) kmeansres<-factor(km$cluster) s.class(df1,fac=kmeansres, add.plot=true, col=rainbow(nlevels(kmeansres)))
there possibility add data frame information cluster observation come from?
you have information want:
kmeansres<-factor(km$cluster)
just add data frame additional column.
df1$cluster <- km$cluster
Comments
Post a Comment