Skip to content
Prev 155341 / 398513 Next

How to preserve date format while aggregating

Those are not dates!  They are date-times.

aggregate is overkill for a single column.  Something simple like

DT <- seq(Sys.time(), by="4 hours", len=24)
grp <- rbinom(24, 1, p=0.5)
res <- tapply(DT, grp, min)
class(res) <- class(DT)
res

would suffice.
On Mon, 8 Sep 2008, Erich Studerus wrote: