[R] zooreg and window

Katrina Bennett kebennett at alaska.edu
Wed Apr 13 21:18:08 CEST 2011


Hello, I have a following time series data

head(mend.dat)

ID PARAM Year Month Day Value SYM
1 15052500     1 1965     5  15   128   A
2 15052500     1 1965     5  16   135   A
3 15052500     1 1965     5  17   157   A
4 15052500     1 1965     5  18   176   A
5 15052500     1 1965     5  19   198   A
6 15052500     1 1965     5  20   241   A


I have loaded these data into as a zooreg object. The entire time
series runs from 1965-05-15 until 2010-12-31.

I have generated dates using ISOdatetime.

regts.start <- ISOdatetime(year.start, mo.start, day.start, hour=0,
min=0, sec=0, tz="GMT")
regts.end <- ISOdatetime(year.end, mo.end, day.end, hour=0, min=0,
sec=0, tz="GMT")

Then, I generate a zoo time series from the data.

zts <- zooreg(mend.dat$Value, start = regts.start, end = regts.end,
frequency = 1, deltat = 86400)

I now want to subset using window.

window(zts, start=as.Date("2000-01-01"), end=as.Date("2000-01-02"))

This results in the following error message.


Data:
factor(0)
1496 Levels:  100 1000 10000 101 1010 10100 102 1020 103 1030 104 1040
105 1050 10500 106 1060 107 1070 108 1080 ... Eqp

Index:
character(0)
Warning messages:
1: In which(in.index & all.indexes >= start & all.indexes <= end) :
  Incompatible methods ("Ops.POSIXt", "Ops.Date") for ">="
2: In which(in.index & all.indexes >= start & all.indexes <= end) :
  Incompatible methods ("Ops.POSIXt", "Ops.Date") for "<="


Why is this happening?

Thanks for your help.

Katrina Bennett



More information about the R-help mailing list