base R中的CET/CEST日光节约检测例行程序
我正在处理众所周知的夏令时问题,这可能是重复。我能找到对我的问题没有帮助的地方。我的独特问题是,我在时间步长的第二次出现时有一个数据间隙base R中的CET/CEST日光节约检测例行程序,r,dst,R,Dst,我正在处理众所周知的夏令时问题,这可能是重复。我能找到对我的问题没有帮助的地方。我的独特问题是,我在时间步长的第二次出现时有一个数据间隙“2015-10-25 02:00:00”。这似乎是问题所在,并导致一小时后在“2015-10-25 03:00:00” 在做示例数据时,我发现有时重新启动R会话会产生不同的结果 新会话上的Testdata: Sys.setenv(TZ="Europe/Berlin") ts1 <- c(seq(as.POSIXct("2015-10-25 02:00:
“2015-10-25 02:00:00”
。这似乎是问题所在,并导致一小时后在“2015-10-25 03:00:00”
在做示例数据时,我发现有时重新启动R会话会产生不同的结果
新会话上的Testdata:
Sys.setenv(TZ="Europe/Berlin")
ts1 <- c(seq(as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin"), by = 600, length.out = 12 ))
ts2 <- c(seq(as.POSIXct("2015-10-25 01:40:00", tz="Europe/Berlin"), by = 1200, length.out = 9 ))
ts3 <- ts2[c(1,2,3,4,6,7,8,9)]
在那之后再跑一次
ts1 <- c(seq(as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin"), by = 600, length.out = 12 ))
最后,这个
ts4 = c(as.POSIXct("2015-10-25 01:40:00", tz="Europe/Berlin"),
as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin"),
as.POSIXct("2015-10-25 02:20:00", tz="Europe/Berlin"),
as.POSIXct("2015-10-25 02:40:00", tz="Europe/Berlin"),
as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin"),
as.POSIXct("2015-10-25 02:20:00", tz="Europe/Berlin"),
as.POSIXct("2015-10-25 02:40:00", tz="Europe/Berlin"),
as.POSIXct("2015-10-25 03:00:00", tz="Europe/Berlin"),
as.POSIXct("2015-10-25 03:20:00", tz="Europe/Berlin"))
导致
> ts4
[1] "2015-10-25 01:40:00 CEST" "2015-10-25 02:00:00 CEST" "2015-10-25 02:20:00 CEST"
[4] "2015-10-25 02:40:00 CEST" "2015-10-25 02:00:00 CEST" "2015-10-25 02:20:00 CEST"
[7] "2015-10-25 02:40:00 CEST" "2015-10-25 03:00:00 CET" "2015-10-25 03:20:00 CET"
如您所见,第二次运行的ts1
给出了正确的DST。这使得再现性变得一团糟。实际上,ts4
是在复制我的问题。但在我的真实数据中,我在第二个时间点有数据gab,这可能不是问题所在。。。我希望这是众所周知的,有人有一个解决办法。我希望有一个基本的解决方案
编辑:
所以这似乎是问题的核心:
Restarting R session...
> as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin")
[1] "2015-10-25 02:00:00 CET"
> as.POSIXct("2015-10-25 01:40:00", tz="Europe/Berlin")
[1] "2015-10-25 01:40:00 CEST"
> as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin")
[1] "2015-10-25 02:00:00 CEST"
> rm(list = ls())
> as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin")
[1] "2015-10-25 02:00:00 CEST"
> as.POSIXct("2015-10-25 03:00:00", tz="Europe/Berlin")
[1] "2015-10-25 03:00:00 CET"
> as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin")
[1] "2015-10-25 02:00:00 CET"
背后的例程是什么?在哪里可以找到它李>as.POSIXct
- 关于R的信息存储在哪里决定2:00是CET还是CEST李>
- 你知道为什么这会在长时间序列中失败吗?关于相同的时间序列ts2(定义为序列->正确的DST)和ts4(单分量向量->错误的DST)
> ts4
[1] "2015-10-25 01:40:00 CEST" "2015-10-25 02:00:00 CEST" "2015-10-25 02:20:00 CEST"
[4] "2015-10-25 02:40:00 CEST" "2015-10-25 02:00:00 CEST" "2015-10-25 02:20:00 CEST"
[7] "2015-10-25 02:40:00 CEST" "2015-10-25 03:00:00 CET" "2015-10-25 03:20:00 CET"
Restarting R session...
> as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin")
[1] "2015-10-25 02:00:00 CET"
> as.POSIXct("2015-10-25 01:40:00", tz="Europe/Berlin")
[1] "2015-10-25 01:40:00 CEST"
> as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin")
[1] "2015-10-25 02:00:00 CEST"
> rm(list = ls())
> as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin")
[1] "2015-10-25 02:00:00 CEST"
> as.POSIXct("2015-10-25 03:00:00", tz="Europe/Berlin")
[1] "2015-10-25 03:00:00 CET"
> as.POSIXct("2015-10-25 02:00:00", tz="Europe/Berlin")
[1] "2015-10-25 02:00:00 CET"