title: Replace Some Variable Values with Variable Names
body: <p>A package ('related') requires me to change some values withing variables in a largeish SNP dataframe (385x12300). This is no doubt simple but I can't find this particular question anywhere.  Sample data: </p>
  
  <pre><code>binfrom&lt;-c(1,1,1,1,0,NA)
  x &lt;- sample(binfrom, 100, replace = TRUE)
  x&lt;-data.frame(matrix(x,10,10))
  </code></pre>
  
  <p>I need the variable names X1,X2 etc to replace each "1" in that variable column. The values "0" and "NA" remain unchanged. </p>