You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the names function should return the "correct" names even for an empty object
Minimal, reproducible example
``` r
library(xts)
data(sample_matrix)
sample.xts<- as.xts(sample_matrix, descr='my new xts object')
names(sample.xts["2007"]) # ok#> [1] "Open" "High" "Low" "Close"sample.xts["0000"]# ok#> Open High Low Close
names(sample.xts["0000"]) # not OK#> NULL
### Session Info
```r
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tidyxts_0.0.0.0009 xts_0.10-0 zoo_1.8-0 bindrcpp_0.2
loaded via a namespace (and not attached):
[1] Rcpp_0.12.14 rstudioapi_0.7 whisker_0.3-2 bindr_0.1 xml2_1.1.1
[6] magrittr_1.5 roxygen2_6.0.1 usethis_1.1.0.9000 devtools_1.13.4 tidyselect_0.2.3
[11] lattice_0.20-35 R6_2.2.2 rlang_0.1.6 stringr_1.2.0 dplyr_0.7.4
[16] tools_3.4.2 grid_3.4.2 withr_2.1.1 timetk_0.1.0 commonmark_1.4
[21] rprojroot_1.3-1 yaml_2.1.16 digest_0.6.13 assertthat_0.2.0 tibble_1.3.4
[26] crayon_1.3.4 purrr_0.2.4.9000 clisymbols_1.2.0 testthat_2.0.0 memoise_1.1.0
[31] glue_1.2.0 stringi_1.1.6 compiler_3.4.2 backports_1.1.2 lubridate_1.7.1
[36] pkgconfig_2.0.1
The text was updated successfully, but these errors were encountered:
Thanks for the report. I can confirm this is a bug, since it's not consistent with zoo:
R>sample.zoo<- as.zoo(sample.xts)
R> names(sample.zoo["2007"]) # ok
[1] "Open""High""Low""Close"R>sample.zoo["0000"]# okOpenHighLowCloseR> names(sample.zoo["0000"]) # not OK
[1] "Open""High""Low""Close"
I'll investigate. Also, it would be great if you could test with the latest development versions of xts and zoo, to ensure the bug you're about to report isn't already fixed.
After some investigation, it appears this behavior is caused by coredata.xts() returning an empty vector for zero-length xts objects. Whereas coredata.zoo() returns the original object, stripped of all its zoo-related attributes.
Description
names of empty xts are NULL
Expected behavior
the names function should return the "correct" names even for an empty object
Minimal, reproducible example
The text was updated successfully, but these errors were encountered: