title: Time series to data frame
body: <p><strong>AIM:</strong> To convert a time series object to a data frame.</p>
  
  <p><strong>DATA:</strong> <code>datasets::Seatbelts</code></p>
  
  <p><strong>PROBLEM:</strong> This is a time series object that has as timestamp a month and a year. I want to extract the month and year in separate columns. See: </p>
  
  <pre><code>&gt; Seatbelts
           DriversKilled drivers front rear   kms PetrolPrice VanKilled law
  Jan 1969           107    1687   867  269  9059     0.10297        12   0
  Feb 1969            97    1508   825  265  7685     0.10236         6   0
  Mar 1969           102    1507   806  319  9963     0.10206        12   0
  Apr 1969            87    1385   814  407 10955     0.10087         8   0
  May 1969           119    1632   991  454 11823     0.10102        10   0
  Jun 1969           106    1511   945  427 12391     0.10058        13   0
  Jul 1969           110    1559  1004  522 13460     0.10377        11   0
  </code></pre>
  
  <p>I have already read this post: </p>
  
  <p><a href="https://stackoverflow.com/questions/25353002/converting-ts-object-to-data-frame">Converting ts object to data.frame</a></p>
  
  <p>The issue with that solution:</p>
  
  <pre><code>data.frame(as.matrix(seatbelts), date=time(seatbelts))
  </code></pre>
  
  <p>Is that I get a column date with only the year, the month seems to be lost:</p>
  
  <pre><code>&gt; data.frame(as.matrix(seatbelts), date=time(seatbelts))
      DriversKilled drivers front rear   kms PetrolPrice VanKilled law date
  1             107    1687   867  269  9059     0.10297        12   0 1969
  2              97    1508   825  265  7685     0.10236         6   0 1969
  3             102    1507   806  319  9963     0.10206        12   0 1969
  4              87    1385   814  407 10955     0.10087         8   0 1969
  5             119    1632   991  454 11823     0.10102        10   0 1969
  6             106    1511   945  427 12391     0.10058        13   0 1969
  </code></pre>
  
  <p>I want either a date column with month and year, or a separate column for both date and year. </p>