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

Michael Green mig at data-intelligence.dk
Thu Sep 16 13:22:21 CEST 2010


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)
plot(x)

This works fine, but

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

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



More information about the R-help mailing list