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

Constructors should not allow NA in index #173

Closed
joshuaulrich opened this issue Mar 30, 2017 · 1 comment
Closed

Constructors should not allow NA in index #173

joshuaulrich opened this issue Mar 30, 2017 · 1 comment
Assignees
Labels

Comments

@joshuaulrich
Copy link
Owner

Both xts() and .xts() allow vectors with NA to be passed to order.by. merge.xts() throws an error if there are NA in the index, so the constructors should not allow them.

R> na <- c(NA, 1:9)
R> x <- .xts(1:10, na)
Error in .xts(1:10, na) : index is not in  increasing order
R> merge(x, x)
nan, nan
Error in merge.xts(x, x) : 'NA' not allowed in 'index'
R> y <- xts(1:10, .POSIXct(na))
R> merge(y, y)
nan, nan
Error in merge.xts(y, y) : 'NA' not allowed in 'index'
@joshuaulrich
Copy link
Owner Author

And thanks to @kylebalkissoon for the (offline) discussion and reproducible example that helped track down this bug.

joshuaulrich added a commit that referenced this issue May 16, 2017
Several xts functions expect all index values to be finite. The most
important of them is merge.xts(). The constructors now error if any
potential index values are NA, NaN, or +/-Inf.

Fixes #173.
joshuaulrich added a commit that referenced this issue Jun 26, 2017
The check for finite index values was very early in the xts
constructor, which could cause problems if order.by wasn't strictly
a numeric vector (e.g. if it was POSIXlt--a list). This was to ensure
the index doesn't contain +/-Inf, NA, or NaN (see #173).

Move the check until after the index has been converted to
POSIXct/numeric, so we can be certain it is a numeric vector.

Fixes #194.
joshuaulrich added a commit that referenced this issue Jun 26, 2017
The check for finite index values was very early in the xts
constructor, which could cause problems if order.by wasn't strictly
a numeric vector (e.g. if it was POSIXlt--a list). This was to ensure
the index doesn't contain +/-Inf, NA, or NaN (see #173).

Move the check until after the index has been converted to
POSIXct/numeric, so we can be certain it is a numeric vector.

Fixes #194.
joshuaulrich added a commit that referenced this issue Jun 26, 2017
The check for finite index values was very early in the xts
constructor, which could cause problems if order.by wasn't strictly
a numeric vector (e.g. if it was POSIXlt--a list). This was to ensure
the index doesn't contain +/-Inf, NA, or NaN (see #173).

Move the check until after the index has been converted to
POSIXct/numeric, so we can be certain it is a numeric vector.

Fixes #194.
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

1 participant