title: Replacing subsets in R with Tidyverse
body: <p>How do one replace the values of a subset in R with <code>Tidyverse</code>? </p>
  
  <p>Using the <code>cars</code> data as an example, if I would like to change all the <code>speed</code> lower than 30 into 0, I can use the command below:</p>
  
  <pre><code> cars[cars["speed"] &lt; 30,] &lt;- 0
  </code></pre>
  
  <p>With <code>Tidyverse</code>, one can generate the same subset with more readable commands:</p>
  
  <pre><code> cars %&gt;% filter(speed &lt; 30) %&gt;% mutate(speed =0)
  </code></pre>
  
  <p>However, this is changing the subset of data we have taken out from <code>cars</code>, not the values of observations within <code>cars</code>. </p>
  
  <p>I might have missed something obvious but is there an intuitive way to do the same thing with <code>Tidyverse</code> as well? While <code>cars[cars["speed"] &lt; 30,] &lt;- 0</code> works fine in most cases, it becomes really unwieldy when one has more than 5 conditions to meet.</p>