0

I am trying to implement k-means clustering using Kmeans in R. I have a data set df containing 4 columns (a,b,c,d). I have implemented k-means clustering using the following code:

result <- Kmeans(df,4,iter.max = 20, nstart = 25, method="euclidean")

When I try to plot the data set using the plot function it shows multiple graph with two attributes each.

plot(df, col=result$cluster)

But I want to plot all the attributes in the same graph. Is it possible? How can I achieve my goal?

camille
  • 16,432
  • 18
  • 38
  • 60
enamul17
  • 159
  • 2
  • 3
  • 14
  • 1
    You cannot plot 4 dimensions in a graph where each dimension is on a perpendicular axis. The best you can do is to plot 3D graphs with 3 dimensions. However, you can also use size, color, transparency or other attributes as dimensions. – yusuzech Oct 21 '19 at 20:18
  • Well, what do you want a four dimensional plot to look like? This doesn't seem to be a specific programming question since you don't seem to know what you want. If you have a general question seeking advice for data visualization, such questions are on topic for [stats.se], not Stack Overflow. At the very least on this site you should provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output. – MrFlick Oct 21 '19 at 20:18
  • You could plot your results in a [parallel coordinate plot](https://www.r-bloggers.com/parallel-coordinate-plots-for-discrete-and-categorical-data-in-r-a-comparison/). On the x axis you plot each coordinate as a category. – R. Schifini Oct 22 '19 at 02:04

0 Answers0