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"), ...)
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
Post a Comment