# a 2-dimensional example
x<-rbind(matrix(rnorm(100,sd=0.3),ncol=2),
matrix(rnorm(100,mean=1,sd=0.3),ncol=2))
cl<-cmeans(x,2,20,verbose=TRUE,method="cmeans",m=2)
print(cl)
# a 3-dimensional example
x<-rbind(matrix(rnorm(150,sd=0.3),ncol=3),
matrix(rnorm(150,mean=1,sd=0.3),ncol=3),
matrix(rnorm(150,mean=2,sd=0.3),ncol=3))
cl<-cmeans(x,6,20,verbose=TRUE,method="cmeans")
print(cl)
# assign classes to some new data
y<-rbind(matrix(rnorm(33,sd=0.3),ncol=3),
matrix(rnorm(33,mean=1,sd=0.3),ncol=3),
matrix(rnorm(3,mean=2,sd=0.3),ncol=3))
# ycl<-predict(cl, y, type="both")
Run the code above in your browser using DataLab