Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subsetting using [.xts drops classes when zero-width #359

Closed
shikokuchuo opened this issue Oct 19, 2021 · 0 comments
Closed

Subsetting using [.xts drops classes when zero-width #359

shikokuchuo opened this issue Oct 19, 2021 · 0 comments
Assignees
Labels
Milestone

Comments

@shikokuchuo
Copy link

shikokuchuo commented Oct 19, 2021

Description

Subsetting using [.xts drops classes when zero-width.

Think the culprit is the use of .xts() in if (length(j) == 0 || ... This is another inconsistency for zero-width objects like #355 although unrelated.

Expected behavior

All classes to be retained consistent with other subsetting.

Minimal, reproducible example

> object <- as.xts(AirPassengers)
> class(object) <- c("custom", "xts", "zoo")
> class(object)
[1] "custom" "xts"    "zoo"   
> class(object[,0])
[1] "xts" "zoo"

Session Info

R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS/LAPACK: /opt/intel/oneapi/mkl/2021.4.0/lib/intel64/libmkl_rt.so.1

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
 [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] xts_0.12.1 zoo_1.8-9 

loaded via a namespace (and not attached):
[1] compiler_4.1.1  tools_4.1.1     grid_4.1.1      lattice_0.20-45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants