title: How to change the values in a column using for loop
body: <p>I want to change the values of column based on an if-else conditions and am using FOR loop to do that. The data is shown below:</p>
  
  <pre><code>m1 m2 m3 a1 a2
  0.5 0.7 0.2 10 20
  0.1 0 0.2 30 40
  </code></pre>
  
  <p>I want to apply the following condition </p>
  
  <pre><code>ifelse(column &gt; 0.5,1,0)
  </code></pre>
  
  <p>I tried using this code, but its not working:</p>
  
  <pre><code>for (k in 1:3){
    data$m[k] &lt;- ifelse(data$m[k] &gt; 0.5,1,0)
    }
  </code></pre>
  
  <p>I also tried using double square brackets [[ ]], but that's also not working. I used the same logic for a list which worked fine, but in this case the column names are string and am not sure how to change the code accordingly.</p>