I have a vector of dates I am trying to cast into datetime
using lubridate
. Some of these are in different timezones, so I have another variable of the same length using appropriate timezones.
By default, it seems like lubridate tz
does not deal with getting a vector input:
library(lubridate)
test = rep(as.character(Sys.time()), 3)
timezones = c('GMT', 'US/Pacific', 'US/Pacific')
ymd_hms(test, tz = timezones)
This produces the following error:
Error in C_force_tz(time, tz = tzone, roll) :
`tz` argument must be a single character string
In addition: Warning message:
In if (tz != "UTC") { :
the condition has length > 1 and only the first element will be used
I believe there is an lapply solution, and I can conjure up a for loop for this, but I'm convinced there's an elegant way to do this!