Re: [R] aggregation of a zoo object

From: Achim Zeileis <>
Date: Tue, 29 May 2007 22:01:04 +0200 (CEST)

On Tue, 29 May 2007 wrote:

> # then I want to do the sum per hour
> z_sum_per_hour <- aggregate(na.omit(z), function(x) as.POSIXct(trunc(x,
> "hour")),sum)
> Warning message:
> some methods for ‚€œzoo‚€ objects do not work if the index entries in
> ‚€˜‚€™ are not unique in: zoo(rval[i], x.index[i])
> Do anyone has an idea how to avoid that ?

The warning does not come from the aggregate() call, but from the na.omit() call. After omitting the NAs, you have still duplicated time stamps, hence the warning is issued again. After that, aggregating works fine and produces no warnings.
Z mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 29 May 2007 - 20:05:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 May 2007 - 20:33:24 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.