[R] Problem with zoo::window()
Agustin Lobo
Agustin.Lobo at ictja.csic.es
Tue Sep 27 11:23:31 CEST 2011
I have the following time series:
> class(CCasadesz2)
[1] "zoo"
> setmanes <- cut(time(CCasadesz2),breaks="weeks")
> CCasadeswz <- aggregate(CCasadesz2,sum,by=setmanes)
> class(CCasadeswz)
[1] "zoo"
> summary(CCasadeswz)
Index CCasadeswz
2009-01-12 00:00:00: 1 Min. : 4.0
2009-01-19 00:00:00: 1 1st Qu.: 150.0
2009-01-26 00:00:00: 1 Median : 268.0
2009-02-02 00:00:00: 1 Mean : 316.6
2009-02-09 00:00:00: 1 3rd Qu.: 387.5
2009-02-23 00:00:00: 1 Max. :1435.0
(Other) :93
> summary(time(CCasadeswz))
shows dates for 2009 and 2010, and
> plot(CCasadeswz)
correctly displays the data for 2009 and 2010.
But when I try to select year 2010:
> CCasadeswz2010 = window(CCasadeswz,start=as.Date("2010-01-01"),
end=as.Date("2010-12-31"))
Warning messages:
1: In which(in.index & all.indexes >= start & all.indexes <= end) :
Incompatible methods ("Ops.factor", "Ops.Date") for ">="
2: In which(in.index & all.indexes >= start & all.indexes <= end) :
Incompatible methods ("Ops.factor", "Ops.Date") for "<="
> summary(CCasadeswz2010)
Index
2009-01-12 00:00:00:0
2009-01-19 00:00:00:0
2009-01-26 00:00:00:0
2009-02-02 00:00:00:0
2009-02-09 00:00:00:0
2009-02-16 00:00:00:0
(Other) :0
(it seems no data have been selected!)
> plot(CCasadeswz2010)
Error in plot.window(xlim = xlim, ylim = ylim, log = log, yaxs =
pars$yaxs) :
need finite 'ylim' values
Calls: plot ... boxplot -> boxplot.default -> do.call -> bxp -> plot.window
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
5: In is.na(rows) : is.na() applied to non-(list or vector) of type 'NULL'
Error in plot.window(xlim = xlim, ylim = ylim, log = log, yaxs =
pars$yaxs) :
need finite 'ylim' values
Calls: plot ... boxplot -> boxplot.default -> do.call -> bxp -> plot.window
why do I get the warning in window()? My command follows what is
mentioned in the manual:
R> window(z, start = as.Date("2005-02-15"), end = as.Date("2005-02-28"))
Thanks
Agus
--
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
Lluis Sole Sabaris S/N
08028 Barcelona
Spain
Tel. +34 934095410
Fax. +34 934110012
email: Agustin.Lobo at ictja.csic.es
More information about the R-help
mailing list