Skip to content

Instantly share code, notes, and snippets.

@MarkEdmondson1234
Created September 22, 2015 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkEdmondson1234/43548374576916f22296 to your computer and use it in GitHub Desktop.
Save MarkEdmondson1234/43548374576916f22296 to your computer and use it in GitHub Desktop.
kResults <- data.frame(k_data, cluster = k$cluster)
## Transform data for columns of cluster, rows of Sku with value of mean total for each
rl <- as.data.frame(lapply(1:4, function(x){ r3 <- kResults[kResults$cluster == x,
setdiff(names(kResults), 'cluster')]
r4 <- colSums(r3) / nrow(r3)
r4
}))
names(rl) <- paste("cluster",1:4)
## plot using d3heatmap library
library(d3heatmap)
d3heatmap(rl, theme="dark", scale = 'row')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment