title: case_when or ifelse with date variables in R
body: <p>I am trying to do the following manipulation to my dataset: if date1 &gt; date2 then date1 = date2, else date1.</p>
  <p>My current code which is not working:</p>
  <pre><code>dfnew &lt;- dfold %&gt;% 
    case_when(date1 &gt; date2 ~ date1 == date2)
  </code></pre>
  <p>or</p>
  <pre><code>dfnew &lt;- dfold %&gt;% 
    ifelse(date1 &gt; date2, date1 == date2, date1)
  </code></pre>
  <p>For example, if date1 = 2020-06-03 and date2 = 2020-06-01 then date1 = date2.</p>
  <p>Neither of these seem to be working for me.</p>