jtleek / modules

97 stars 894 forks source link

Wrong resulting picture #86

Open agent18 opened 5 years ago

agent18 commented 5 years ago

Please correct this. Its in the coursera slides as well. kmeansObj2$cluster needs to be used instead of kmeansObj$cluster. Like me many people spent time to understand what it was supposed to do, when it is a really simple thing

Heatmaps

set.seed(1234)
dataMatrix <- as.matrix(dataFrame)[sample(1:12), ]
kmeansObj2 <- kmeans(dataMatrix, centers = 3)
par(mfrow = c(1, 2), mar = c(2, 4, 0.1, 0.1))
image(t(dataMatrix)[, nrow(dataMatrix):1], yaxt = "n")
image(t(dataMatrix)[, order(kmeansObj2$cluster)], yaxt = "n")
agent18 commented 5 years ago

From this part: https://github.com/jtleek/modules/tree/master/04_ExploratoryAnalysis/kmeansClustering; Sorry I don't know the proper way of submitting requests!