r - Plotting a cluster with [1*n] matrix variable -


i beginner when comes r. trying plot clusters (after estimating them, of course) of data set (2 variables). used

kmeans(x, centers, iter.max = 10, nstart = 1,        algorithm = c("hartigan-wong", "lloyd", "forgy",                      "macqueen"), trace=false) ## s3 method class 'kmeans' fitted(object, method = c("centers", "classes"), ...)  

cluster vector

and got point, quite unsure how should proceed in order graph showing 1 variable on x , other on y axis clusters indicated.

how should go it?

thanks!

ok think should do:

result<-kmeans(x,centers,...)  plot(data$x,data$y, col=result$cluster) 

that plot data , color respective observation depending cluster is. can add center of clusters

points(result$clusters, col=1:2, pch=18,cex=2)  

the last 2 commands pch , cex center points like.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -