as.POSIXct的奇怪行为

时间:2017-12-12 10:01:51

标签: r

我在理解R中函数as.Posixct的行为时遇到了一些麻烦。似乎02:00:00 2015-03-29周围发生了一些事情:

as.POSIXct("2015-03-29 02:57:53", format="%Y-%m-%d %H:%M:%S")
[1] NA

as.POSIXct("2015-03-29 01:57:53", format="%Y-%m-%d %H:%M:%S")
[1] "2015-03-29 01:57:53 CET"

as.POSIXct("2015-03-29 03:57:53", format="%Y-%m-%d %H:%M:%S")
[1] "2015-03-29 03:57:53 CEST"

为了确认这一点,我还尝试了以下代码

time_seq_before <- seq(from = as.POSIXct("2015-03-29 01:00:00"),
                       to = as.POSIXct("2015-03-29 01:59:59"),
                       by = 1)
length(time_seq_before)
[1] 3600

time_seq_after <- seq(from = as.POSIXct("2015-03-29 03:00:00"),
                      to = as.POSIXct("2015-03-29 03:59:59"),
                      by = 1)
length(time_seq_after)
[1] 3600

time_seq <- seq(from = as.POSIXct("2015-03-29 01:59:59"),
                to = as.POSIXct("2015-03-29 03:00:00"),
                by = 1)
length(time_seq)
[1] 2
time_seq
[1] "2015-03-29 01:59:59 CET"  "2015-03-29 03:00:00 CEST"

有人能够解释这里发生的事情吗?谢谢!

0 个答案:

没有答案