title: Error in ts(x) : 'ts' object must have one or more observations
body: <p>When I do forecast using <code>forecast</code> library, I noticed following code does not run as expected:</p>
  
  <pre><code>library(forecast)
  library(dplyr)
  df1 &lt;- data.frame(gp=gl(20,5), dt=seq(1:100))
  
  get &lt;- function (df1){
    ts1 &lt;- ts((df1%&gt;%filter(gp==2))$dt)
    as.numeric(forecast(ar(ts1),15)$mean)
  }    
  
  print(get(df1))
  </code></pre>
  
  <p>The error return is:</p>
  
  <blockquote>
    <p>Error in ts(x) : 'ts' object must have one or more observations</p>
  </blockquote>
  
  <p>May be it is caused by <code>ar</code> or <code>ar.burg</code> function. Because if you change the function to <code>ets</code> or something else the function works well.</p>
  
  <p>What is more strange is that if you change the code to:</p>
  
  <pre><code>library(forecast)
  library(dplyr)
  df1 &lt;- data.frame(gp=gl(20,5), dt=seq(1:100))
  ts1 &lt;- ts((df1%&gt;%filter(gp==2))$dt)
  
  get &lt;- function (ts1){
    as.numeric(forecast(ar(ts1),15)$mean)
  }
  
  
  print(get(ts1))
  </code></pre>
  
  <p>The code is also running correctly. I think this may be a bug in <code>ar</code> function, and the problem is somehow related to scope. Any thoughts about this?</p>