title: Conditional calculation based on values in other column
body: <p>Suppose I have a <code>data.frame</code>, I wish to create a new column called <code>duration</code>, it is calculated only for records where <code>status = Active</code>, using <code>2016-12-10</code> as today's date, so that <code>duration = today - start_date</code>.</p>
  
  <p>What's the best approach for this conditional calculation?</p>
  
  <pre><code>status &lt;- c("Active", "Inactive", "Active")    
  date &lt;- c("2016-10-25", "2015-05-11", "2015-3-18")    
  start_date &lt;- as.Date(date, format = "%Y-%m-%d")    
  data.frame(status, start_date)
  </code></pre>