I just want to know that can we stop the aggregate converting datetimes to the computer's local timezone? Say, for instance:
dtUTC <- as.POSIXct(c('2010-01-01 01:01:01', '2015-01-02 07:23:11',
'2016-06-02 05:23:41', '2018-01-08 17:57:43'), tz='UTC')
groups <- c(1,1,2,2)
result <- aggregate(dtUTC, by=list(groups), FUN=min)
The result is converted to my computer's local timezone.
> dtUTC
[1] "2010-01-01 01:01:01 UTC" "2015-01-02 07:23:11 UTC" "2016-06-02 05:23:41 UTC"
[4] "2018-01-08 17:57:43 UTC"
> result$x
[1] "2010-01-01 12:01:01 AEDT" "2016-06-02 15:23:41 AEST"
I can convert it back post hoc but I am having multiple datetime columns, how can I do that?
attr(result$x, 'tzone') <- 'UTC'
> result$x
[1] "2010-01-01 01:01:01 UTC" "2016-06-02 05:23:41 UTC"