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

.parseISO8601() if statement may have length > 1 logical #280

Closed
joshuaulrich opened this issue Nov 27, 2018 · 0 comments
Closed

.parseISO8601() if statement may have length > 1 logical #280

joshuaulrich opened this issue Nov 27, 2018 · 0 comments
Assignees
Labels
Milestone

Comments

@joshuaulrich
Copy link
Owner

joshuaulrich commented Nov 27, 2018

Thanks to Kurt Hornik for this report! xts will fail R CMD check on recent R-devel if run with: _R_CHECK_LENGTH_1_LOGIC2_=package:_R_CHECK_PACKAGE_NAME_,abort,verbose

The lines that triggers the error is in test.i_invalid_date_string():

x <- xts(1:10, as.Date("2015-02-20")+0:9)
y <- x["2015-02-30"]  # error triggered in .parseISO8601() called here

The specific line in .parseISO8601() is:
if(is.na(s) && is.na(e) && !nzchar(DURATION) && intervals != "").

This is because intervals is only length-1 and equal to "" when [.xts is called with a value for i that is only a separator (e.g. "/" or "::").

The printed values after each call are some examples of the values of intervals during different subset calls:

R> y <- x["/",]
[1] ""
R> y <- x["/2015",]
[1] ""     "2015"
R> y <- x["2015/",]
[1] "2015"
R> y <- x["2015-02-28",]
[1] "2015-02-28" "2015-02-28"
R> y <- x["2015-02-30",]
[1] "2015-02-30" "2015-02-30"
@joshuaulrich joshuaulrich self-assigned this Nov 27, 2018
@joshuaulrich joshuaulrich added this to the 0.12-0 milestone Jul 4, 2019
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