title: error position must be between 0 and n in function that filters and sums by date ranges
body: <p>For the following sample dataset:</p>
  
  <pre><code>set.seed(123)
  library(dplyr)
  Sessions &lt;- ceiling(rnorm(50, mean = 3000, sd = 300))
  Registrations &lt;- ceiling(rnorm(50, mean = 800, sd = 100))
  Conversions &lt;- ceiling(rnorm(50, mean = 400, sd = 50))
  Date_Range = seq(Sys.Date() - 50, Sys.Date() - 1, by = 1)
  sample_data &lt;- data.frame(Date_Range,Sessions, Registrations, Conversions)
  sample_data &lt;- tbl_df(sample_data)
  </code></pre>
  
  <p>I have the following function which is meant to provide sum total of a given metric for a date range:</p>
  
  <pre><code>sumByDates &lt;- function(startDate, endDate, metric) {
      sum(filter(sample_data, Date_Range &gt;= startDate &amp; Date_Range &lt;= endDate) %&gt;% select(metric))
  }
  </code></pre>
  
  <p>Now if I do this:</p>
  
  <pre><code>sumByDates(Sys.Date()-5, Sys.Date()-1, Sessions)
  </code></pre>
  
  <p>I would get:</p>
  
  <pre><code>Error: Position must be between 0 and n
  Called from: combine_vars(vars, ind_list)
  Browse[1]&gt; Q
  </code></pre>
  
  <p>How can I sum a given metric in <code>sample_data</code> for a given <code>Date_Range</code>?</p>