日期时间字符串中缺少 :00 值

missing :00 values from date-time string

我有一个大型日期时间序列 (%Y-%m-%d %H:%M:%S),内容如下:

[1] 2009-10-16 00:04:30 2009-10-16 00:04:40 2009-10-16 00:04:50 2009-10-16 00:05   
[5] 2009-10-16 00:05:10 2009-10-16 00:05:20

基本上每一步时间增加 10 秒。但是,整整一分钟 :00 都丢失了,并且在我将日期时间转换为 as.POSIXct 时导致出现问题。 (我得到 NA)。

我该如何纠正这个问题?

我可能只是测试字符串的长度...

a <- c("2009-10-16 00:04:30", "2009-10-16 00:04:40", "2009-10-16 00:04:50", "2009-10-16 00:05", "2009-10-16 00:05:10", "2009-10-16 00:05:20")
nchar(a)
[1] 19 19 19 16 19 19
a[nchar(a)==16] <- paste0(a[nchar(a)==16], ":00")
a
[1] "2009-10-16 00:04:30" "2009-10-16 00:04:40" "2009-10-16 00:04:50"
[4] "2009-10-16 00:05:00" "2009-10-16 00:05:10" "2009-10-16 00:05:20"