title: Replace dummy output with another value on same row whenever value equal to 1 in R
body: <p>Looking for a simple way to copy the VAL variable in any of the LINE.x (could be 100s of LINE.x) variables that are 1 for every row. In the end all the LINE.x variables with a value of one should be replaced by the VAL decimal value on that same row. Thanks!</p>
  
  <pre><code>USR_ID LINE.1 LINE.2 LINE.3.LINE.4 LINE.5 LINE.6 LINE.7 LINE.8 LINE.9    VAL
  210       1      0      0             0      0      0      0      0      0 21.343
  213       0      0      1             0      0      0      0      0      0  2.340
  34        0      0      0             0      0      0      0      0      1 23.760
  5433      1      0      0             0      0      0      0      0      0  0.300
  </code></pre>
  
  <p>To this:</p>
  
  <pre><code>USR_ID LINE.1 LINE.2 LINE.3.LINE.4 LINE.5 LINE.6 LINE.7 LINE.8 LINE.9    VAL
  210  21.343      0   0.00             0      0      0      0      0   0.00 21.343
  213   0.000      0   2.34             0      0      0      0      0   0.00  2.340
  34    0.000      0   0.00             0      0      0      0      0  23.76 23.760
  5433  0.300      0   0.00             0      0      0      0      0   0.00  0.300
  </code></pre>
  
  <p>Here is the fictitious data set:</p>
  
  <pre><code>df1 &lt;- read.table(textConnection("USR_ID,LINE.1,LINE.2,LINE.3 LINE.4,LINE.5,LINE.6,LINE.7,LINE.8,LINE.9,VAL
  210,1,0,0,0,0,0,0,0,0,21.343
  213,0,0,1,0,0,0,0,0,0,2.34
  34,0,0,0,0,0,0,0,0,1, 23.76
  5433,1,0,0,0,0,0,0,0,0,0.3"), sep=",", header=TRUE)
  </code></pre>