0

I have the following zoo-object and I can't plot it. It doesn't make sense to me. Why?!

structure(c(-2.7, -3.9, -8.1, -6, -7.3, -15.9, -15.5, -6.3, -10.8, 
-12.9, -9.6, -1.7, -4.2, -7.8, -11.2, -12.2, -11.9, -16.2, -11.8, 
-7.9, -7.9, -6.5, -6.8, -10.3, -7, -5.5, -5.7, -4, -4.8, -2.5, 
0.4, -1.4, 1.5, 2, 0.2, -2.4, -2.7, -4, -2.3, -3.2), index = c("2017-01-01", 
"2017-01-02", "2017-01-03", "2017-01-04", "2017-01-05", "2017-01-06", 
"2017-01-07", "2017-01-08", "2017-01-09", "2017-01-10", "2017-01-11", 
"2017-01-12", "2017-01-13", "2017-01-14", "2017-01-15", "2017-01-16", 
"2017-01-17", "2017-01-18", "2017-01-19", "2017-01-20", "2017-01-21", 
"2017-01-22", "2017-01-23", "2017-01-24", "2017-01-25", "2017-01-26", 
"2017-01-27", "2017-01-28", "2017-01-29", "2017-01-30", "2017-01-31", 
"2017-02-01", "2017-02-02", "2017-02-03", "2017-02-04", "2017-02-05", 
"2017-02-06", "2017-02-07", "2017-02-08", "2017-02-09"), class = "zoo")
plot(ts)

Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
zx8754
  • 52,746
  • 12
  • 114
  • 209
talocodat
  • 25
  • 5

1 Answers1

1

The index of your data is of class character (test with class(index(your_data)), thus not usable as time coordinates (the error message ... need finite 'xlim' values ... gives a clue). You need to convert your index to a suitable class, e.g.:

library(zoo)

index(your_data) <- as.Date(index(your_data))