按时间子选择R XTS对象,从而导致重复的行

时间:2017-02-03 21:13:32

标签: r xts

我有一个XTS对象,我正在按时间进行选择,但得到的结果不正确。我正在寻找凌晨2点到4点之间的时间,但是子选择是重复行而不是抓住正确的时间。以下是示例数据的链接:https://drive.google.com/file/d/0B2nxylGXOp81QTZMajdqT1MtNWM/view?usp=sharing

以下是解释问题的代码:

library(xts)
Sys.setenv('TZ'='America/Chicago')
SampleData <- readRDS('SampleData.rds')
CutSampleData <- SampleData['T02:00/T16:00']

head(CutSampleData)   ## shows it did not subselect out the correct range 
any(duplicated(as.character(index(CutSampleData))))  ## shows there are duplicated rows

CutSampleData["2016-03-11 15:02:00"]  ## here is a duplicated row.  What is going on?

编辑: 看起来这个问题可能与Linux vs Windows或其他一些版本问题有关。它在此会话信息的框中正确

R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RMySQL_0.10.9 DBI_0.5-1     Quandl_2.8.0  xts_0.9-7     zoo_1.7-13   

loaded via a namespace (and not attached):
[1] httr_1.2.1      R6_2.1.3        tools_3.3.1     grid_3.3.1      jsonlite_1.0    lattice_0.20-33

但不适用于此sessionInfo:

R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 14393)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base   

为什么这会破坏Windows的任何想法?是否与XTS如何处理POSIXct时间有关?

0 个答案:

没有答案