title: convert data to binary in R using apply function
body: <p>I have a dataframe called reshapedwcw as follows. I want to use the apply function to convert the data to binary data where the value is present
      reshapewcw</p>
  
  <pre><code>    D009325 D009357 D009369 D009373 D009404 D009437 D009442 D009447  
  r1    1       0       0       2       0       0       44      78        
  r2    0       3       4       0       2       1       2       2 
  r3    1       2       1       2       3       87      99      2  
  </code></pre>
  
  <p>Desired Output</p>
  
  <pre><code>    D009325 D009357 D009369 D009373 D009404 D009437 D009442 D009447 
  r1    1       0       0       1       0       0       1       1               
  r2    0       1       1       0       1       1       1       1        
  r3    1       1       1       1       1       1       1       1    
  </code></pre>
  
  <p>In addition, kindly let me what is wrong with this approach and is there a better alternative</p>
  
  <pre><code>indices &lt;- which(apply(reshapedwcw,2,function(x) x&gt;1)) 
  reshapedwcw[indices]&lt;-1
  </code></pre>