title: extracting column headers
body: <p>I have the following data frame (data) from which I will like to extract and print column headers where ever there is a non-zero element:</p>
  
  <pre><code>  M1 M2 M3 M4
  2  0  1  0 1
  5  1 -1  0 0
  7  0  1  1 0
  </code></pre>
  
  <p>Required output:</p>
  
  <pre><code>2: M2 M4
  5: M1 M2
  7: M2 M3 
  </code></pre>
  
  <p>So far my R code is not working:</p>
  
  <pre><code>colnames(data)[which(data[2] !=0),]
  </code></pre>
  
  <p>Help will be appreciated. Thanks</p>