title: dealing with NA in seasonal cycle analysis R
body: <p>I have a timeseries of monthly data with lots of missing datapoints, set to NA.  I want to simply subtract the annual cycle from the data, ignoring the missing entries.  It seems that the decompose function can't handle missing data points, but I have seen elsewhere that the seasonal package is suggested instead.  However I am also running into problems there too with the NA.</p>
  
  <p>Here is a minimum reproducible example of the problem using a built in dataset...</p>
  
  <pre><code>library(seasonal)
  
  # set range to missing NA in Co2 dataset
  c2&lt;-co2
  c2[c2&gt;330 &amp; c2&lt;350]=NA
  seas(c2,na.action=na.omit)
  
  Error in na.omit.ts(x) : time series contains internal NAs
  </code></pre>
  
  <p>Yes, I know! that's why I asked you to omit them! Let's try this:</p>
  
  <pre><code>seas(c2,na.action=na.x13)
  
  Error: X-13 run failed
  
  Errors:
  - Adding MV1981.Apr exceeds the number of regression effects
    allowed in the model (80).
  </code></pre>
  
  <p>Hmmm, interesting, no idea what that means, okay, please just exclude the NA:</p>
  
  <pre><code>seas(c2,na.action=na.exclude)
  
  Error in na.omit.ts(x) : time series contains internal NAs
  </code></pre>
  
  <p>that didn't help much! and for good measure </p>
  
  <pre><code>decompose(c2)
  
  Error in na.omit.ts(x) : time series contains internal NAs
  </code></pre>
  
  <p>I'm on the following:</p>
  
  <pre><code>R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
  Copyright (C) 2018 The R Foundation for Statistical Computing
  Platform: x86_64-pc-linux-gnu (64-bit)
  </code></pre>
  
  <p>Why is leaving out NA such a problem? I'm obviously being completely stupid, but I can't see what I'm doing wrong with the seas function.  Happy to consider an alternative solution using xts.</p>