Christina Karamperidou
2010-Mar-30 19:32 UTC
[R] question on creating zoo object from indexed time series: re-arranges dates
Dear all, I have a time series of daily measurements that starts like this: KWhourly[1:10,] Date Time Value 01/01/13 00:00:00 1.6 01/01/13 01:00:00 1.6 01/01/13 02:00:00 1.6 01/01/13 03:00:00 1.6 01/01/13 04:00:00 1.6 01/01/13 05:00:00 1.6 01/01/13 06:00:00 1.6 01/01/13 07:00:00 1.6 01/01/13 08:00:00 1.6 01/01/13 09:00:00 1.6 I am trying to get average daily, monthly, yearly values using the zoo package. My series starts at 01/01/13 00:00:00 and ends at 12/31/05 23:00:00 I create the zoo object: #z <- zoo(KWhourly$Value,chron(KWhourly$Date, KWhourly$Time)) but then z starts at: start(z) [1] (01/01/30 00:00:00) and ends at: end(z) [1] (12/31/29 23:00:00) instead of going from 01/01/13 to 12/31/05 any ideas why this is happening and how to fix it? I really appreciate your help Christina K. Columbia University ck4545@gmail.com P Please consider the environment - Do you really need to print this email? [[alternative HTML version deleted]]
Gabor Grothendieck
2010-Mar-30 19:48 UTC
[R] question on creating zoo object from indexed time series: re-arranges dates
Not for me. Please provide your data and code in reproducible form as per last line of every r-help message and the posting guide.> Lines <- "Date Time Value+ 01/01/13 00:00:00 1.6 + 01/01/13 01:00:00 1.6 + 01/01/13 02:00:00 1.6 + 01/01/13 03:00:00 1.6 + 01/01/13 04:00:00 1.6 + 01/01/13 05:00:00 1.6 + 01/01/13 06:00:00 1.6 + 01/01/13 07:00:00 1.6 + 01/01/13 08:00:00 1.6 + 01/01/13 09:00:00 1.6"> DF <- read.table(textConnection(Lines), header = TRUE, as.is = TRUE) > library(zoo)Warning message: closing unused connection 3 (Lines)> library(chron) > z <- zoo(DF$Value, chron(DF$Date, DF$Time)) > z(01/01/13 00:00:00) (01/01/13 01:00:00) (01/01/13 02:00:00) (01/01/13 03:00:00) 1.6 1.6 1.6 1.6 (01/01/13 04:00:00) (01/01/13 05:00:00) (01/01/13 06:00:00) (01/01/13 07:00:00) 1.6 1.6 1.6 1.6 (01/01/13 08:00:00) (01/01/13 09:00:00) 1.6 1.6 On Tue, Mar 30, 2010 at 3:32 PM, Christina Karamperidou <ck4545 at gmail.com> wrote:> Dear all, > > I have a time series of daily measurements that starts like this: > > KWhourly[1:10,] > ? ? ? Date ? ? Time Value > 01/01/13 00:00:00 ? 1.6 > 01/01/13 01:00:00 ? 1.6 > 01/01/13 02:00:00 ? 1.6 > 01/01/13 03:00:00 ? 1.6 > 01/01/13 04:00:00 ? 1.6 > 01/01/13 05:00:00 ? 1.6 > 01/01/13 06:00:00 ? 1.6 > 01/01/13 07:00:00 ? 1.6 > 01/01/13 08:00:00 ? 1.6 > 01/01/13 09:00:00 ? 1.6 > > I am trying to get average daily, monthly, yearly values using the zoo package. > > My series starts at 01/01/13 00:00:00 ? and ends at ? 12/31/05 23:00:00 > > I create the zoo object: > > #z <- zoo(KWhourly$Value,chron(KWhourly$Date, KWhourly$Time)) > > but then z starts at: > start(z) > [1] (01/01/30 00:00:00) > > and ends at: > > end(z) > [1] (12/31/29 23:00:00) > > instead of going from 01/01/13 to 12/31/05 > > any ideas why this is happening and how to fix it? > > I really appreciate your help > > > Christina K. > Columbia University > ck4545 at gmail.com > P Please consider the environment - Do you really need to print this email? > > > > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >