How do I create a plotable zoo object based on weekly data?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How do I create a plotable zoo object based on weekly data?

Michael Green
Dear readers,

The problem is simple: I have weekly time series data with a maximum
week number of (52,53,52,52) in (2008,2009,2010,2011) respectively. That
means I have a dataset looking like this:

2008-01 value
2008-02 value
2011-52 value

And I would like to turn that data into a plotable zoo object. Now a
simple example containing 4 data points, each being on the December
28th, would be:
x <- zoo(rnorm(4), as.Date("2008-12-28")+0:3*365)

This works fine, but

y <- zoo(rnorm(4), format(as.Date("2008-12-28")+0:3*365, "%Y-%U"))

gives me the following warning message:

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

Anyone knows how to solve this?

Best regards,
Michael Green

[hidden email] mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.