title: Subset n number of rows from a dataframe based on date criterias from another dataframe
body: <p>I have a dataframe (say Summary) in R:</p>
  
  <pre><code>Begin Date | EndDate | Month | Year | Count
  2/1/2014 | 1/31/2015 | Jan | 2014 | 10
  3/1/2014 | 2/28/2015 | Feb | 2014 | 10
  4/1/2014 | 3/31/2015 | Mar | 2014 | 10
  5/1/2014 | 4/30/2015 | Apr | 2014 | 10
  </code></pre>
  
  <p>Another dataframe (say terms)</p>
  
  <pre><code>Student_Hire_Date | Student_ID
  2/1/2014 | 100001
  2/2/2014 | 100002
  2/3/2014 | 100003
  2/4/2014 | 100004
  2/5/2014 | 100005
  </code></pre>
  
  <p>I need an R code that will populate the column "Count", by taking a subset of data from the Terms table where Student_Hire_Date is between 'BeginDate' and 'EndDate' from Summary Table.</p>
  
  <p>An R code equivalent to : </p>
  
  <pre><code>Summary$Count &lt;- "select count(*) from Terms,Summary 
                    where Terms.Student_Hire_Date between
                        Summary.BeginDate and Summary.EndDate"
                    GROUP BY Summary.EndDate
  </code></pre>
  
  <p>I tried using the following code, but I am getting the same count for every date range.</p>
  
  <pre><code>summary$Count &lt;- nrow(subset(Terms, 
                                !is.na(Student_ID)
                                 &amp; Student_Hire_Date &gt;= as.Date(Summary$BeginDate)
                                  &amp; Student_Hire_Date &lt;= as.Date(Summary$EndDate)
  </code></pre>
  
  <p>Please help!!!!!!</p>