[R] plot clusters

pingzhao pingzhao at waffle.cs.dal.ca
Fri Apr 25 21:45:19 CEST 2003


Hi,

I have a dataset which has more than two clusters (say 3 clusters).
I used kmeans to cluster the dataset.

I am wondering how I can plot the clustering result on a two-dimensional
figure????

The example in the kmeans help file is as follows:

 x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
                matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
     cl <- kmeans(x, 2, 20)
     plot(x, col = cl$cluster)

It seems that this is only working for 2 clusters. When my dataset has more
than two clusters, the plot results are obvious wrong.

Any suggestions to plot more than two clusters.

Thanks!!!



More information about the R-help mailing list