Issue with decomposing xts objects with R
<p>I am unable to figure out with I can't decompose the time series below. Any ideas why ?</p>

<pre><code>data(co2,package = "datasets")
library(lubridate)
library(xts)
plot(co2)#ok
decompose(co2)# ok


my_co2 &lt;- xts(co2,order.by = seq(from=dmy(01011959),to=dmy(01121997),length.out = 468))
plot(my_co2) 
</code></pre>

<p><code>my_co2</code> and <code>co2</code> seem to be identical..</p>

<pre><code>decompose(my_co2) #
</code></pre>

<blockquote>
  <p>Error in decompose(my_co2) : time series has no or less than 2 periods</p>
</blockquote>

<p>I don't understand why this happens. Any ideas?</p>

<p>EDIT :</p>

<pre><code>my_co2_v2 &lt;- xts(frequency = 12,co2,order.by = seq(from=dmy(01011959),to=dmy(01121997),length.out = 468))
frequency(my_co2_v2) # still 1 !
attr(my_co2_v2, 'frequency')&lt;- 12
frequency(my_co2_v2) # ok, it's 12
plot(decompose(my_co2_v2)) # still not good
</code></pre>

<p>you are right <code>plot(decompose(ts(my_co2_v2,frequency = 12)))</code> work, but it seems a little bit twisted. Is there a bug un xts regarding frequency ?</p>