日期时间未转换为as.POSIXct

时间:2019-07-19 21:44:47

标签: r dataframe datetime

as.POSIXct似乎正在产生NA,但我不确定为什么吗?

我尝试将format = "%Y/%m/%d %H:%M"更改为format = "%Y-%m-%d %H:%M",但这没有用。我在这里想念什么?

df$`Local Time` <- as.POSIXct( df$`Local Time`,
                               format = "%Y/%m/%d %H:%M", tz="America/Vancouver")

数据

 df <- structure(list(`UTC Time` = c("2019-06-01 10:03", "2019-06-01 
 10:07", "2019-06-01 11:41", "2019-06-01 13:13", "2019-06-01 13:53", 
 "2019-06-01 14:05"), `Local Time` = c("2019-06-01 3:03", "2019-06-01 
 3:07", "2019-06-01 4:41", "2019-06-01 6:13", "2019-06-01 6:53", "2019- 
 06-01 7:05"), Type = c("Passenger ship", 
 "Passenger ship", "Passenger ship", "Passenger ship", "Passenger 
 ship", "Passenger ship"), Length = c(294, 294, 294, 294, 294, 294)), 
 row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

0 个答案:

没有答案