I'm trying to create a new variable in a data table with format function and I'm using two variables from the data table itself as arguments, but function doesn't recognize one of them. Why?
> dt <- data.table(date = as.POSIXct(c("2018-06-13 11:00:00", "2018-06-13 11:00:00")), time_zone = c("America/Lima", "America/Sao_Paulo"))
> dt
date time_zone
1: 2018-06-13 11:00:00 America/Lima
2: 2018-06-13 11:00:00 America/Sao_Paulo
> dt[, localdate := format(as.POSIXct(date), tz = time_zone, usetz = TRUE)]
Error in as.POSIXlt.POSIXct(x, tz) : invalid 'tz' value