Re: [R] aggregation of a zoo object

From: Achim Zeileis <Achim.Zeileis_at_wu-wien.ac.at>
Date: Tue, 29 May 2007 22:01:04 +0200 (CEST)


On Tue, 29 May 2007 jessica.gervais_at_tudor.lu 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
> ‚€˜order.by‚€™ 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



R-help_at_stat.math.ethz.ch 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. 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.