title: Error making line plot using xts R : cannot mix zero-length and non-zero-length coordinates
body: <p>I'm attempting to slice two data frames, one representing the date (Date) and one representing a continuous value and graph them using a xts line graph. When I use the full dateframes it works, but when I slice to the last 7 values, it throws the following error. Any thoughts? </p>
  
  <p>Error in segments(xlim[1], y_grid_lines(get_ylim()[[2]]), xlim[2], y_grid_lines(get_ylim()[[2]]),  : 
    cannot mix zero-length and non-zero-length coordinates</p>
  
  <pre><code>    library(xts)
  
  Date &lt;- seq(as.Date("2018-01-01"), as.Date("2018-02-25"), by="days")
  Date &lt;- as.POSIXct(Date, format = "%Y-%m-%d %H:%M")
  
  #Date &lt;-tail #Works
  Date &lt;-tail(Date,7) #Doesn't Work
  
  T1_EF &lt;- matrix( rnorm(N*M,mean=23,sd=3), N, M)
  Trial1_EF&lt;- as.matrix(round(Trial1_EF, digits = 6))
  T1_EF_counts &lt;- apply(Trial1_EF, 2, function(x) length(na.omit(x)))
  
  #c &lt;-T1_EF_counts #Works
  c &lt;-tail(T1_EF_counts,7)#doesn't work
  
  
    datN &lt;- data.frame(Date = Date, y = c)
  
  
  
    datN.ts &lt;- xts(datN$y, order.by = datN$Date)
    plot(datN.ts)
    lines(datN.ts, col = 'Green')
  </code></pre>