aggregate over POSIX timestamps not returning unique values
Its a problem with daylight savings time. If you use chron or do this first: Sys.setenv(TZ = "GMT") to put your session into GMT time then daylight savings time won't exist and the problem does not arise. Suggest you read R News 4/1. Also please make code with random numbers reproducible by using set.seed, e.g. set.seed(1) On Thu, Feb 28, 2008 at 3:11 PM, Markus Loecher
<markus at insightfromdata.com> wrote:
I am puzzled by the following observation. It seems that aggregating
over POSIX timestamps sometimes returns duplicate entries in the output.
For example:
tmp <- zoo(cumsum(rnorm(35041)), order.by =
seq(as.POSIXct("2007-01-01 10:00:00"), to = as.POSIXct("2008-01-01
10:00:00"), by = 15*60))
plot(tmp)
tmp.h <- aggregate(coredata(tmp), by =
list(as.POSIXct(trunc(index(tmp),"hour"))), FUN = mean)
plot(zoo(tmp.h[,2], as.POSIXct(as.character(tmp.h[,1]))))
> Warning message: > some methods for "zoo" objects do not work if the index entries
in >'order.by' are not unique in: zoo(tmp.h[, 2], as.POS... When I use the more elegant aggregate.zoo() version of this, the problem is a non issue: tmp.h <- aggregate(tmp, by = as.POSIXct(trunc(index(tmp),"hour")), FUN = mean) I would still l like to understand this, any help would be greatly appreciated, Thanks, Markus
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.