title: R: using stl() on an xts object
body: <p>I'm relatively new to R so please bear with me. I'm trying to get to grips with basic irregular time-series analysis. </p>
  
  <p>That's what my data file looks like, some 40k lines. The spacing is <em>not</em> always exactly 20sec.</p>
  
  <pre><code>Time, Avg
  04/03/2015 00:00:23,20.24
  04/03/2015 00:00:43,20.38
  04/03/2015 00:01:03,20.53
  04/03/2015 00:01:23,20.54
  04/03/2015 00:01:43,20.53
  
   data &lt;- read.zoo("data.csv",sep=",",tz='',header=T,format='%d/%m/%Y %H:%M:%S')
  </code></pre>
  
  <p>I'm happy to aggregate by minutes</p>
  
  <pre><code>data &lt;- to.minutes(as.xts(data))
  </code></pre>
  
  <p>Using the "open" column as an example</p>
  
  <pre><code>head(data[,1])
                      as.xts(data).Open
  2015-03-04 00:00:43             20.24
  2015-03-04 00:01:43             20.53
  2015-03-04 00:02:43             20.47
  2015-03-04 00:03:43             20.38
  2015-03-04 00:04:43             20.05
  2015-03-04 00:05:43             19.84
  
  data &lt;- data[,1]
  </code></pre>
  
  <p>And here is where it all falls apart for me</p>
  
  <pre><code>fit &lt;- stl(data, t.window=15, s.window="periodic", robust=TRUE)
  Error in stl(data, t.window = 15, s.window = "periodic", robust = TRUE) : 
  series is not periodic or has less than two periods
  </code></pre>
  
  <p>I've googled the error message, but it's not really clear to me. Is period = frequency? For my dataset I would expect the seasonal component to be weekly.</p>
  
  <pre><code>frequency(data) &lt;- 52
  fit &lt;- stl(data, t.window=15, s.window="periodic", robust=TRUE)                   
  Error in na.fail.default(as.ts(x)) : missing values in object
  </code></pre>
  
  <p>?</p>
  
  <pre><code>head(as.ts(data))
  [1] 20.24    NA    NA    NA    NA    NA
  </code></pre>
  
  <p>Uh, what?</p>
  
  <p>What am I doing wrong? How do I have to prepare the xts object to be able to properly pass it to stl()?</p>
  
  <p>Thank you.</p>