title: create intervals with criteria in R
body: <p>This is my head(both)</p>
  
  <pre><code>     start        end          omreg
  1 2011-01-19    2012-09-21     TRUE
  2 2012-01-19          &lt;NA&gt;     FALSE
  3 2007-09-01          &lt;NA&gt;     FALSE
  4 2011-09-01    2012-01-11     FALSE
  5 2008-09-01          &lt;NA&gt;     FALSE
  6 2013-09-01    2014-06-12     TRUE
  </code></pre>
  
  <p>As seen, I have a start date and an end date.</p>
  
  <p>The data are for students who started a course on a specific date and end date shows when they were finished with the course.</p>
  
  <p>Each term lasts for 160 days. Which means that one semester lasts for 160 days. 2 semesters of 320 days, etc ...</p>
  
  <p>The interest lies in wether the students passed the course after 160, 320 or 480 days, etc ...</p>
  
  <p>I want to create columns for each semester</p>
  
  <p>Where:
  passed = true
  failed = false</p>
  
  <p>to pick up students who fared within 160 days i made: </p>
  
  <pre><code>    gdk&lt;-(difftime(as.Date(both$end), as.Date(both$start), 
  
  units="days") &lt; 160 &amp; !both$omreg)
  </code></pre>
  
  <p>But then I get trouble picking up students who were ready</p>
  
  <p>between 160 and 320 days.</p>
  
  <p>i.e. &lt;= 320 but  >160 days.</p>
  
  <p>Perhaps easier to say in the interval [160, 320] days ...</p>
  
  <p>This perhaps was a bit messy explained, but I did my best to try to explain my problem.</p>
  
  <p>And what I need help with is how to change the code above to be able to pick out the desired range.</p>