James McCreight
2011-May-27 16:29 UTC
[R] lubridate, as.POSIXct and a vector of times: bug or feature??
It took me some time to realize this annoying behavior was coming from lubridate. Perhaps this behavior is unexpected a result of cursory knowledge of it.... ## The expected behavior> sometimes=c(0,1,2,3)*60*60*24 > as.POSIXct( sometimes, origin='1970-01-01', tz='GMT')[1] "1970-01-01 GMT" "1970-01-02 GMT" "1970-01-03 GMT" "1970-01-04 GMT"> require(lubridate)Loading required package: lubridate Overriding + and - methods for POSIXt, Date and difftime ## no respect for the tz argument when somtimes is a vector> as.POSIXct( sometimes, origin=origin, tz='GMT')[1] "1969-12-31 17:00:00 MST" "1970-01-01 17:00:00 MST" [3] "1970-01-02 17:00:00 MST" "1970-01-03 17:00:00 MST" ## it is not just a result of lubridate's origin>as.POSIXct( sometimes, origin='1970-01-01', tz='GMT')[1] "1969-12-31 17:00:00 MST" "1970-01-01 17:00:00 MST" [3] "1970-01-02 17:00:00 MST" "1970-01-03 17:00:00 MST" [[alternative HTML version deleted]]