Closed alkment closed 6 years ago
The error specifically is this.
> testxts['2017'][as.Date('2018-07-17')]
Error in if (j < 1 || idx[j] != dt) break :
missing value where TRUE/FALSE needed
This may? fix the problem ( prevent NAs from creeping in )
from
> debug(window_idx)
> testxts['2017'][as.Date('2018-07-17')]
debug at <tmp>#23: match <- idx[base_idx] == index.
one may do
> fixInNamespace(x = "window_idx", ns = "xts")
# replace line
match <- idx[base_idx] == index.
# by lines
### match <- idx[base_idx] == index.
### prevent NAs from creeping in
match <- sapply({idx[base_idx] == index.}, function(x) { if(is.na(x)) { FALSE } else { x } } )
SAVE notepad
So, now works as exptected.
> testxts['2017'][as.Date('2018-07-17')]
[,1]
> str(testxts['2017'][as.Date('2018-07-17')])
An 'xts' object of zero-width
> devtools::session_info()
Session info ------------------------------------------------------------------
setting value
version R version 3.5.1 (2018-07-02)
system x86_64, mingw32
ui RTerm
language (EN)
collate English_United States.1252
tz America/Chicago
date 2018-07-22
Packages ----------------------------------------------------------------------
package * version date source
base * 3.5.1 2018-07-02 local
compiler 3.5.1 2018-07-02 local
datasets * 3.5.1 2018-07-02 local
devtools 1.13.6 2018-06-27 CRAN (R 3.5.1)
digest 0.6.15 2018-01-28 CRAN (R 3.5.0)
graphics * 3.5.1 2018-07-02 local
grDevices * 3.5.1 2018-07-02 local
grid 3.5.1 2018-07-02 local
lattice 0.20-35 2017-03-25 CRAN (R 3.5.0)
magrittr * 1.5 2014-11-22 CRAN (R 3.5.0)
memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
methods * 3.5.1 2018-07-02 local
rstudioapi 0.7 2017-09-07 CRAN (R 3.5.0)
stats * 3.5.1 2018-07-02 local
tools 3.5.1 2018-07-02 local
utils * 3.5.1 2018-07-02 local
withr 2.1.2 2018-04-27 Github (jimhester/withr@79d7b0d)
xts * 0.11-0 2018-07-16 CRAN (R 3.5.1)
zoo * 1.8-3 2018-07-16 CRAN (R 3.5.1)
Subsetting by date behavior changed in case of empty xts
After upgrading from 10-2 to 11-0 subsetting an empty xts by a date throws an error.
Expected behavior
The pre 11-0 behavior was to return an empty xts.
Minimal, reproducible example
Session Info