title: R lubridate interval class for labeling axis
body: <p>This is my "old" method of creating a label vector for labeling the axis of a plot.</p>
  
  <pre><code>require(lubridate)
  require(dplyr)
  
  #old
  version &lt;- "201710" 
  endDate = as.Date(paste0(version,"01"), "%Y%m%d")                                         
  startDateString = paste0(as.integer(substr(version, 1, 4)) - 3,substr(version, 5, 6))  
  startDate = as.Date(paste0(startDateString,"01"), "%Y%m%d")                               
  datehv &lt;- format(seq(startDate, endDate, "3 months"), "%Y-%m")                            
  
  zeitbereich = c()                                    
  for(i in 1:(length(datehv)-1)) {              
    zeitbereich = c(zeitbereich, datehv[i], "", "")       
  }
    zeitbereich = c(zeitbereich, datehv[length(datehv)])
  labels &lt;- substr(zeitbereich,1,7)
  </code></pre>
  
  <p>Below is the new version. The idea is to use lubridate and dplyr for better readability and a simpler syntax</p>
  
  <pre><code>#new
  version2 &lt;- "201710"  
  endDate2 = ymd(paste0(version,"01"))
  startDate2 = endDate2 - dyears(3)
  zeitbereich2 &lt;- interval(startDate2, endDate2)
  </code></pre>
  
  <p>How can I get the vector "labels" as in the old code to be generated from the new time interval?</p>
  
  <p>a) ignoring the "" spots in the labels vector of #old</p>
  
  <p>b) incorporating empty "" in the labels vector</p>