【问题标题】:xts subset - daylight savings timexts 子集 - 夏令时
【发布时间】:2017-12-03 06:56:03
【问题描述】:

我正在尝试索引 1 分钟频率数据集的特定分钟数。 (我一直使用 'T../T..' 因为 .indexmin 有(/has?)一些problems with timezones.

以下两个 xts 对象具有相同的长度(nrow),没有重复,下面的子集应该返回零(凌晨 2 点没有 obs)。一个有效,另一个无效(返回所有 obs)。我认为这与 DST 过渡有关(尽管两者都以 EDT 作为索引)。 Sys.timezone() 也设置为 EST5EDT。任何想法如何解决这一问题?

xcheck1 <- readRDS(gzcon(url("https://dl.dropboxusercontent.com/s/8yg9q854umipjna/xts_problem_1.rds"))) 
xcheck2 <- readRDS(gzcon(url("https://dl.dropboxusercontent.com/s/qm83b0ayz03appg/xts_problem_2.rds")))
xcheck1['T02:00/T02:00:10']
xcheck2['T02:00/T02:00:10']

【问题讨论】:

    标签: r timezone subset xts


    【解决方案1】:

    它是a bug,已在最新的 CRAN 版本 (0.10-0) 中得到修复。现在,在这两种情况下,它都会返回您所期望的(无)。

    library(xts)
    Sys.setenv(TZ = "EST5EDT")
    urls <- paste0("https://dl.dropboxusercontent.com/s/",
                   c("8yg9q854umipjna", "qm83b0ayz03appg"),
                   "/xts_problem_", 1:2, ".rds")
    xcheck1 <- readRDS(gzcon(url(urls[1])))
    xcheck2 <- readRDS(gzcon(url(urls[2])))
    xcheck1['T02:00/T02:00:10']
    #      AUDUSD.ask.Close
    xcheck2['T02:00/T02:00:10']
    #      AUDUSD.ask.Close
    packageVersion("xts")
    # [1] '0.10.0'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-24
      • 2013-06-25
      • 2017-07-27
      • 2012-08-02
      • 1970-01-01
      • 2013-02-18
      • 2011-02-22
      • 2012-04-25
      相关资源
      最近更新 更多