title: Check for Date in Datespan for multiple times
body: <p>i have data that looks like this:   </p>
  
  <pre><code>Data &lt;- "Person Address Starting.Date  Resignation.Date Job
   John         abc       01.01.2017    03.01.2017        IT      
    Sarah        cde      06.01.2017 06.07.2017       Teacher
    Susi         bfg     09.06.2017  08.09.2017     secretary"
  Data &lt;- read.table(text=zz, header = TRUE)
  </code></pre>
  
  <p>My goal is to find out how long people stayed in their job before quitting and put that information in a new variable. So i check if the resignation date is in a certain datespan, what I do by using this Code:</p>
  
  <pre><code>Data$Span&lt;- ifelse(Data$Resignation.Date&gt;= "01.01.2017" &amp; Data$Resignation.Date &lt;= "31.01.2017", 1, 
                                ifelse(Data$Resignation.Date&gt;= "01.02.2017" &amp; Data$Resignation.Date &lt;= "28.02.2017", 2,
                                       ifelse(Data$Resignation.Date&gt;= "01.03.2017" &amp; Data$Resignation.Date &lt;= "31.03.2017", 3,
                                              ifelse(Data$Resignation.Date&gt;= "01.04.2017" &amp; Data$Resignation.Date &lt;= "30.04.2017", 4,
                                                     ifelse(Data$Resignation.Date&gt;="01.05.2017" &amp; Data$Resignation.Date &lt;= "31.05.2017",5, 
                                                            ifelse(Data$Resignation.Date&gt;="01.06.2017" &amp; Data$Resignation.Date&lt;="30.06.2017",6, 
                                                                   ifelse(Data$Resignation.Date&gt;="01.07.2017" &amp; Data$Resignation.Date&lt;="31.07.2017",7, 
                                                                          ifelse(Data$Resignation.Date&gt;="01.08.2017" &amp; Data$Resignation.Date&lt;="31.08.2017", 8,
                                                                                 ifelse(Data$Resignation.Date&gt;="01.09.2017" &amp; Data$Resignation.Date&lt;="30.09.2017", 9,
                                                                                        ifelse(Data$Resignation.Date&gt;="01.10.2017" &amp; Data$Resignation.Date&lt;="31.10.2017",10,
                                                                                               ifelse(Data$Resignation.Date&gt;="01.11.2017" &amp; Data$Resignation.Date&lt;="30.11.2017", 11,
                                                                                                      ifelse(Data$Resignation.Date&gt;="01.12.2017" &amp; Data$Resignation.Date&lt;="31.12.2017",12,999))))))))))))
  </code></pre>
  
  <p>The data I presented is for a subset for People who started working in January. I have subsets for all 12 months in 2017. What I want to do is use the same Code for People who started working in February / March / and so on. To do this I would have to alter the Code in that it starts with the first line and adds one month and then adds one month for all following lines. So that for example for the February subset it would start with</p>
  
  <pre><code>Data$Resignation.Date&gt;= "01.02.2017" &amp; Data$Resignation.Date &lt;= "28.02.2017.2017", 1,
  </code></pre>
  
  <p>and end with</p>
  
  <pre><code> ifelse(Data$Resignation.Date&gt;="01.01.2018" &amp; Data$Resignation.Date&lt;="31.01.2018",12,999
  </code></pre>
  
  <p>Is there any way to do this without copy pasting the Code and doing the changes manually for every month? Since the changes follow a certain systematic I would think that it would be possible, but I could not find any solution for this. I looked for Solutions in the dplyr package since I thought that my Problem fits there, but that did not help me. I would be very thankful for any advice. Of Course I will happily answer remaining questions.</p>
  
  <p>P.S.: I am not not attached to using the subsets, that was just easier for me to work with since I am not so experienced in r. I filtered the subsets by using this Code</p>
  
  <pre><code>Data &lt;- TotalData[TotalData$Starting.Date&gt;= "01.01.2017" &amp; TotalData$Starting.Date &lt;= "31.01.2017",]
  </code></pre>