title: Transform a matrix so that it can be plotted with heatmap in R
body: <p>I have a matrix that I want to visualize in heatmap, with ggplot, such as geom_tile in R. The data are current in the format of</p>
  
  <pre><code>   I   II
  A  1   2
  B  3   4
  </code></pre>
  
  <p>However, to use ggplot, I need to transform this matrix into a data frame in the format like this:</p>
  
  <pre><code>Var1   Var2   Value
  A      I      1
  A      II     2
  B      I      3
  B      II     4
  </code></pre>
  
  <p>How do I transform the matrix to this format so that I can use ggplot? I don't want visualization package such as gplot because it seems a lot slower. Thanks.</p>