title: Excel SUMIFS equivalent in R
body: <p>I'm very very new to R and am looking at ways of recreating an Excel VBA macro and Excel worksheet functions such as SUMIFS.  SUMIFS sums a column if the row has entries matching multiple conditions on its other columns.</p>
  
  <p>I have the below data frame and I want to compute a new column. The new column is the sum of <code>Sample</code> for all rows that overlap with the <code>Start Date</code> and <code>EndDate</code> range.  For example on line <code>1</code> it would be <code>697</code> (the sum of the first <code>3 lines</code>).  The criteria for the sum specifically: include <code>Sample</code> if <code>EndDate &gt;= StartDate[i] &amp; StartDate &lt;=EndDate[i]</code></p>
  
  <pre><code> StartDate   EndDate    Sample  *SUMIFS example*
   10/01/14   24/01/14    139         *697*
   12/01/14   26/01/14    136 
   19/01/14   02/02/14    422 
   25/01/14   08/02/14    762 
   29/01/14   12/02/14    899 
   05/02/14   19/02/14    850 
   07/02/14   21/02/14    602 
   09/02/14   23/02/14    180 
   18/02/14   04/03/14    866 
  </code></pre>
  
  <p>Any comments or pointers would be greatly appreciated.</p>