I have a dataframe with timestamps (UTC) and the respective timezones they should be converted to. I would like to create a converted_time_zone column using local timezone.
timestamp time_zone
1 2016-09-17 11:00:00 "America/Vancouver"
2 2016-09-17 10:00:00 "America/Los_Angeles"
3 2016-09-17 15:00:00 "America/Montreal"
4 2016-09-17 12:00:00 "America/Vancouver"
5 2016-09-17 13:00:00 "America/Maceio"
I have tried several methods but nothing has worked like expected including:
for(i in 1:nrow(df)) {
df$converted_timestamp[i] = with_tz(df$timestamp[i], df$time_zone[i])
i = i + 1
}
or
df$converted_timestamp = with_tz(df$timestamp, df$time_zone)