as.POSIXct() 为特定日期时间生成 NA
as.POSIXct() produces NA for specific date times
我目前正在使用 R 分析大约 4 万条推文。因此,我正在使用 as.POSIXct()
将文本转换为日期。虽然这适用于几乎所有行,但我在集合中有两行导致 NA
被返回。
我已经将它缩小到特定日期的一小时时间跨度(见下文)。也可以更改其他任何内容(年、月等)。
dateFormat <- "%Y-%m-%d %H:%M:%S"
working1 <- as.POSIXct("2014-03-30 01:59:59", format = dateFormat)
### everything in between does not work
working2 <- as.POSIXct("2014-03-30 03:00:00", format = dateFormat)
### These were the original dates:
notWorking1 <- as.POSIXct("2014-03-30 02:39:21", format = dateFormat)
notWorking2 <- as.POSIXct("2014-03-30 02:33:28", format = dateFormat)
我不确定我是否发现了错误或者这是我的错,因为我还在学习 R。
正如 Ronak 在评论中所指出的,这是 DST 问题。
It works for me but I am guessing from I already narrowed it down to a one-hour-timespan on a specific date
if it is related to Daylight saving in your time zone ?
我目前正在使用 R 分析大约 4 万条推文。因此,我正在使用 as.POSIXct()
将文本转换为日期。虽然这适用于几乎所有行,但我在集合中有两行导致 NA
被返回。
我已经将它缩小到特定日期的一小时时间跨度(见下文)。也可以更改其他任何内容(年、月等)。
dateFormat <- "%Y-%m-%d %H:%M:%S"
working1 <- as.POSIXct("2014-03-30 01:59:59", format = dateFormat)
### everything in between does not work
working2 <- as.POSIXct("2014-03-30 03:00:00", format = dateFormat)
### These were the original dates:
notWorking1 <- as.POSIXct("2014-03-30 02:39:21", format = dateFormat)
notWorking2 <- as.POSIXct("2014-03-30 02:33:28", format = dateFormat)
我不确定我是否发现了错误或者这是我的错,因为我还在学习 R。
正如 Ronak 在评论中所指出的,这是 DST 问题。
It works for me but I am guessing from
I already narrowed it down to a one-hour-timespan on a specific date
if it is related to Daylight saving in your time zone ?