title: R draw kmeans clustering with heatmap
body: <p>I would like to cluster a matrix with kmeans, and be able to plot it as heatmap. It sounds quite trivial, and I have seen many plots like this. I have tried to google atround, but can't find a way round it. </p>
  
  <p>I'd like to be able to plot something like panel A or B on this figure. 
  Let say I have a matrix with 250 rows and 5 columns. I don't want to cluster the columns, just the rows. </p>
  
  <pre><code>m = matrix(rnorm(25), 250, 5)
  
  km = kmeans(m, 10)
  </code></pre>
  
  <p>Then how do I plot those 10 clusters as a heatmap ? You comments and helps is more than welcome. </p>
  
  <p>Thanks.</p>
  
  <p><img src="https://i.stack.imgur.com/Cpl4b.jpg" alt="enter image description here"></p>