Skip to content
Prev 29989 / 63433 Next

aggregate() does not return POSIXct object correctly (PR#12887)

rene.locher at zhaw.ch wrote:
This is as documented, possibly annoying, but not a bug.

aggregate() is documented to build on tapply() for which the discarding
of class is documented on ?tapply. The root cause is unlist():
$A
[1] "2008-01-01 CET"

$B
[1] "2008-01-04 CET"
A          B
1199142000 1199401200

and a partial rationale is that unlist() wouldn't know what to do if the
arguments had different classes.
The workaround is, of course, just to stick the class back on.