title: R pick up the starting date and ending date of the Recession period
body: <p>I'm trying to plot the Recession Shading periods in R. Consider the following example, recession periods are recognized as 1, and non recession periods are 0.</p>
  
  <pre><code>Date           Recession  
  1918-09-01     1  
  1918-10-01     1  
  1918-11-01     1  
  1918-12-01     1  
  1919-01-01     1  
  1919-02-01     1  
  1919-03-01     1  
  1919-04-01     0  
  1919-05-01     0  
  1919-06-01     0  
  1919-07-01     0  
  1919-08-01     0  
  1919-09-01     0  
  1919-10-01     0  
  1919-11-01     0  
  1919-12-01     0  
  1920-01-01     0  
  1920-02-01     1  
  1920-03-01     1  
  1920-04-01     1  
  1920-05-01     1  
  </code></pre>
  
  <p>Can anyone help me to pick up the starting date and ending dates of the recession periods? For example:    </p>
  
  <pre><code>Start                 End
  1918-09-01     1919-03-01
  1920-02-01     1920-05-01
  </code></pre>
  
  <p>The same question has been asked few years ago, but I think the answer is not able solve this question. see <a href="https://stackoverflow.com/questions/21739012/r-recession-dates-conversion">R Recession Dates Conversion</a></p>
  
  <p>Thanks in advance!</p>