title: Replacing values from a column using a condition in R
body: <p>I have a very basic <code>R</code> question but I am having a hard time trying to get the right answer. I have a data frame that looks like this:</p>
  <pre><code>species &lt;- &quot;ABC&quot;
  ind &lt;- rep(1:4, each = 24)
  hour &lt;- rep(seq(0, 23, by = 1), 4)
  depth &lt;- runif(length(ind), 1, 50)
      
  df &lt;- data.frame(cbind(species, ind, hour, depth))
  df$depth &lt;- as.numeric(df$depth)
  </code></pre>
  <p>What I would like it to select AND replace all the rows where <code>depth &lt; 10</code> (for example) with zero, but I want to keep all the information associated to those rows and the original dimensions of the data frame.</p>
  <p>I have try the following but this does not work.</p>
  <pre><code>df[df$depth&lt;10] &lt;- 0 
  </code></pre>
  <p>Any suggestions?</p>