Yang Ming
Yang Ming

Reputation: 1

how to generate any graphics to help better visualize the clusters

I have used k-means method to separate some data into two subgroups. What I get is the label (1 or 2) of each sample. Do any of you know how to visualize the clusters? Many thanks!

Upvotes: 0

Views: 25

Answers (1)

Señor O
Señor O

Reputation: 17432

Here's a start:

> data = data.frame(x = rnorm(100), y = rnorm(100))
> k = kmeans(data, centers = 4)
> plot(y ~ x, data=data, col=k$cluster)

enter image description here

Upvotes: 1

Related Questions