title: Time series decomposition in R
body: <p>I've recently started dabbling with some time-series analysis in R, and I'm a little confused as to how the filter function in the stats library works. Essentially, I've seen it asserted that, for a daily time series, that filter could be used to decompose the series into yearly, seasonal and weekly components using something like the following:</p>
  
  <pre><code>x.year &lt;- filter(x, rep(1/365, 365))
  x.season &lt;- filter(x, rep(1/90, 90))
  x.weekly &lt;- filter(x, rep(1/7, 7))
  </code></pre>
  
  <p>While I can figure out that the rep(1/period, period) gives you a component of length period, I'm not sure <em>why</em>, and am trying to avoid cargo cult analysis. Consulting the documentation, that bit is apparently, "a vector of filter coefficients in reverse time order" - just not sure what that means.</p>
  
  <p>Anyone care to point me in the right direction?</p>