[R] aggregation of a zoo object
Achim Zeileis
Achim.Zeileis at wu-wien.ac.at
Tue May 29 22:01:04 CEST 2007
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
More information about the R-help
mailing list