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

Creating and subsetting empty xts objects removes dim attr #402

Open
joshuaulrich opened this issue Jul 6, 2023 · 0 comments
Open

Creating and subsetting empty xts objects removes dim attr #402

joshuaulrich opened this issue Jul 6, 2023 · 0 comments

Comments

@joshuaulrich
Copy link
Owner

joshuaulrich commented Jul 6, 2023

xts objects should almost always have a dim attribute, but these xts objects do not have dims.

I say "almost always" because merge.xts() has removed the 'dim' attribute from zero-column results since the beginning of time. It will very likely break stuff if we set dim(result) <- c(0, 0) because users probably use is.null(dim(x))... xts even does this internally.

x <- xts(numeric(0), .Date(integer(0)))
dim(x)
## NULL
dim(x[0,])
## NULL
dim(x[Sys.Date(),])
## NULL

Strangely, the .xts() constructor adds dims to an empty object and says it has 1 column. I expected it to be c(0, 0) instead.

x. <- .xts(numeric(0), .POSIXct(numeric(0)))
dim(x.)
## [1] 0 1

This is a regression from version 0.12.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant