title: "Unnesting" a dataframe in R
body: <p>I have the following <code>data.frame</code>:</p>
  
  <pre><code>df &lt;- data.frame(id=c(1,2,3), 
                   first.date=as.Date(c("2014-01-01", "2014-03-01", "2014-06-01")), 
                   second.date=as.Date(c("2015-01-01", "2015-03-01", "2015-06-1")),
                   third.date=as.Date(c("2016-01-01", "2017-03-01", "2018-06-1")),
                   fourth.date=as.Date(c("2017-01-01", "2018-03-01", "2019-06-1")))
  
  &gt; df
  
    id first.date second.date third.date fourth.date
  1  1 2014-01-01  2015-01-01 2016-01-01  2017-01-01
  2  2 2014-03-01  2015-03-01 2017-03-01  2018-03-01
  3  3 2014-06-01  2015-06-01 2018-06-01  2019-06-01
  </code></pre>
  
  <p>Each row represents three timespans; i.e. the time spans between <code>first.date</code> and <code>second.date</code>, <code>second.date</code> and <code>third.date</code>, and <code>third.date</code> and <code>fourth.date</code> respectively.</p>
  
  <p>I would like to, in lack of a better word, unnest the dataframe to obtain this instead:</p>
  
  <pre><code>  id  StartDate    EndDate
  1  1 2014-01-01 2015-01-01
  2  1 2015-01-01 2016-01-01
  3  1 2016-01-01 2017-01-01
  4  2 2014-03-01 2015-03-01
  5  2 2015-03-01 2017-03-01
  6  2 2017-03-01 2018-03-01
  7  3 2014-06-01 2015-06-01
  8  3 2015-06-01 2018-06-01
  9  3 2018-06-01 2019-06-01
  </code></pre>
  
  <p>I have been playing around with the <code>unnest</code> function from the <code>tidyr</code> package, but I came to the conclusion that I don't think it's what I'm really looking for.</p>
  
  <p>Any suggestions?</p>