title: Pasting the column name to each value of a dataframe in R
body: <p>Hoping this isn't a repeat- I've had a search around but can't find quite what I'm looking for. </p>
  
  <p>I have a dataframe (df) in R</p>
  
  <pre><code>  1 2 3 4 5 
  1 1 0.5 0.5 0 1
  2 0.5 0.5 0.5 0 1
  3 1 1 0 0 1
  4 1 1 0 0 1 
  5 1 1 0 0 1
  </code></pre>
  
  <p>(with the 1-5 indicating row and column names)</p>
  
  <p>I would like to paste the column name to each cell, separated by a ":" so that it looks like this:</p>
  
  <pre><code>  1 2 3 4 5 
  1 1:1 2:0.5 3:0.5 4:0 5:1 
  2 1:0.5 2:0.5 3:0.5 4:0 5:1 
  3 1:1 2:1 3:0 4:0 5:1 
  4 1:1 2:1 3:0 4:0 5:1 
  5 1:1 2:1 3:0 4:0 5:1 
  </code></pre>
  
  <p>However, my actual data is quite a bit larger. </p>
  
  <p>I currently have</p>
  
  <pre><code>apply(df, 2, function(x) paste(colnames(df)[x], x, sep=":"))
  </code></pre>
  
  <p>Of course this doesn't work as colnames(df)[x] doesn't make any sense. 
  Is there anything I can put in that first 'paste' term to get this sorted? Or another function to do a better job?</p>
  
  <p>Thanks.     </p>