0

So I'm working on K-Modes and plotting right now. The issue is that you need a numeric matrix for K-Modes, which is fine and all until I go to graph. The graph itself looks great, save for the numbers. I want the categorical variables that were converted numerically to be turned back into their respective string counter parts. Here is the example plot. I would like to turn the X values of 1-5 into like Poor, Excellent, Good

Plot

Here is the MVE code

dataFrame <- DATA
for (column in colnames(dataFrame)) {
  dataFrame[[column]] <- as.numeric(dataFrame[[column]])
}
dataFrame <- data.matrix(dataFrame)

cl <- kmodes(dataFrame, 2)
  # plot(dataFrame, col = cl$cluster)
  # points(cl$modes, col = 1:5, pch = 8)
  plot(jitter(dataFrame), col = cl$cluster, main = "Results")
  points(cl$modes, col = 1:10, pch = 8, cex = 20)

DATA can be data frame consisting of only categorical variables (so I suppose you can throw in some strings there?).

Jon
  • 89
  • 1
  • 8
  • 1
    `plot(jitter(dataFrame), col = cl$cluster, main = "Results", xaxt= 'n');axis(1, at=c(1,3,5), labels=c("Poor","Good", "Excelent");points(cl$modes, col = 1:10, pch = 8, cex = 20)` – M-- Aug 11 '17 at 18:34
  • @Masoud Life saver. Thank you! – Jon Aug 11 '17 at 21:29
  • Possible duplicate of [This post](https://stackoverflow.com/a/45619028/4752675) – G5W Aug 14 '17 at 18:36

0 Answers0