0

Says, a dataframe df_1 has 8 columns, and following code is used.

res = kmeans(df_1, 4, nstart=40)

The K-means clustering result is stored in res.

In most examples, two dimensions (i.e. two columns) are used to demonstrate the clustering.

However, in the above code, df_1 has 8 dimensions.

How do I know, which columns were used?

Justin
  • 327
  • 3
  • 13
  • have u checked the cheat sheet ? – sai saran Nov 16 '18 at 07:36
  • @sai sara, I did not check any sheet. I just did some research online and no example showed the criteria of the input data.frame. – Justin Nov 16 '18 at 07:54
  • ?kmeans can u try this one – sai saran Nov 16 '18 at 08:29
  • 1
    Description Perform k-means clustering on a data matrix. Usage kmeans(x, centers, iter.max = 10, nstart = 1, algorithm = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"), trace=FALSE) ## S3 method for class 'kmeans' fitted(object, method = c("centers", "classes"), ...) – sai saran Nov 16 '18 at 08:30
  • 1
    They will all be used. If you want to use only certain columns then limit the columns in the data frame that you pass to the kmeans function – Cleland Nov 16 '18 at 09:32

0 Answers0