title: Converting dataframe with date and time to time series in R
body: <p>I have a dataframe with 13 columns and I wish to convert the dataframe to a time series so that I can perform a seasonal decomposition with <code>stl()</code> </p>
  
  <p>My dataframe looks as follows:</p>
  
  <pre><code>&gt; head(wideRawDF)
      Period.Start.Time DO0182U09A3 DO0182U09B3 DO0182U09C3 DO0182U21A1 DO0182U21A2 DO0182U21A3
  1 2017-01-20 16:30:00     -101.50     -103.37     -103.86     -104.78     -104.95     -105.33
  2 2017-01-20 16:45:00     -101.32     -102.75     -104.22     -104.51     -103.94     -105.29
  3 2017-01-20 17:00:00     -101.45     -103.30     -103.93     -104.70     -104.82     -105.13
  4 2017-01-20 17:15:00     -100.91      -95.92      -99.22     -103.83     -104.72     -105.19
  5 2017-01-20 17:30:00     -100.91     -103.04     -104.09     -102.15     -104.91     -105.18
  6 2017-01-20 17:45:00     -100.97     -103.67     -104.12     -105.07     -104.23      -97.48
    DO0182U21B1 DO0182U21B2 DO0182U21B3 DO0182U21C1 DO0182U21C2 DO0182U21C3
  1     -102.50      -99.43     -104.05     -104.51     -104.42     -105.17
  2     -102.82     -101.99     -103.94     -104.74     -104.65     -105.25
  3     -103.72     -103.95     -104.25     -105.02     -105.04     -105.32
  4     -103.57     -101.36     -104.09     -103.90     -102.95     -105.16
  5     -103.88     -104.09     -103.96     -104.75     -105.07     -105.23
  6     -103.92     -103.89     -104.01     -105.08     -105.14     -104.89
  </code></pre>
  
  <p>As you can see my data is in 15 min intervals.</p>
  
  <p>I have tried converting this to a time series using the following code:</p>
  
  <pre><code>wideRawTS &lt;- as.ts(wideRawDF, start = head(index(wideRawDF), 1), end = tail(index(wideRawDF), 1), frequency = 1)
  </code></pre>
  
  <p>I used frequency equal to 1 since I have 1343 rows of data, each one representing the sampling period.</p>
  
  <blockquote>
    <p>1343/(14*24*4) = 0.999 => 1</p>
  </blockquote>
  
  <p>wideRawTS looks as follows:</p>
  
  <pre><code>head(wideRawTS)
       Period.Start.Time DO0182U09A3 DO0182U09B3 DO0182U09C3 DO0182U21A1 DO0182U21A2 DO0182U21A3 DO0182U21B1 DO0182U21B2 DO0182U21B3
  [1,]        1484929800     -101.50     -103.37     -103.86     -104.78     -104.95     -105.33     -102.50      -99.43     -104.05
  [2,]        1484930700     -101.32     -102.75     -104.22     -104.51     -103.94     -105.29     -102.82     -101.99     -103.94
  [3,]        1484931600     -101.45     -103.30     -103.93     -104.70     -104.82     -105.13     -103.72     -103.95     -104.25
  [4,]        1484932500     -100.91      -95.92      -99.22     -103.83     -104.72     -105.19     -103.57     -101.36     -104.09
  [5,]        1484933400     -100.91     -103.04     -104.09     -102.15     -104.91     -105.18     -103.88     -104.09     -103.96
  [6,]        1484934300     -100.97     -103.67     -104.12     -105.07     -104.23      -97.48     -103.92     -103.89     -104.01
       DO0182U21C1 DO0182U21C2 DO0182U21C3
  [1,]     -104.51     -104.42     -105.17
  [2,]     -104.74     -104.65     -105.25
  [3,]     -105.02     -105.04     -105.32
  [4,]     -103.90     -102.95     -105.16
  [5,]     -104.75     -105.07     -105.23
  [6,]     -105.08     -105.14     -104.89
  </code></pre>
  
  <p>I believe the Period.Start.Time variable has been converted to epoch which is a unix representation of the number of seconds since Jan 1, 1970.</p>
  
  <p>I have subsequently tried passing the time series data, wideRawTS to stl() but now get:</p>
  
  <pre><code>stl(wideRawTS[,2])
  Error in stl(wideRawTS[, 2]) : 
    series is not periodic or has less than two periods
  </code></pre>
  
  <p>I've checked the first few epoch values and they are the correct representations of the original data so I don't know what's going on!</p>
  
  <p>If someone would be so kind as to show me the errors of my way, I would be most grateful.</p>