-
Notifications
You must be signed in to change notification settings - Fork 991
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
X[Y]
Merge Produces Wrong Output When nomatch=0
and roll=T
#700
Comments
@my-R-help, thanks for the report. On your side note, if you just did: CS[SP, nomatch=0L, roll=TRUE] It does warn you: Warning message:
# In cbind(LPERMCO = c(" 7", "33", "33", "33", "33"), datadate = c("2013-07-31", :
# number of rows of result is not a multiple of vector length (arg 3) It just disappears when you wrap it with |
What you wrote is true. However, what I did originally was something like this to save the result into a new data.table (which is a common use pattern, I believe), and here no warning appeared: M <- CS[SP, nomatch = 0, roll = T] |
Michael, |
The patch still gives different column lengths when run on the example code above. |
@my-R-help, I am not sure. This is what I get: > CS[SP, roll=TRUE, nomatch=0L]
LPERMCO datadate me RET
1: 7 2013-07-31 626550.353 0.141225
2: 33 2013-07-31 7766.385 0.045967
3: 33 2013-07-31 7766.385 0.043694
sapply(CS[SP, roll=TRUE, nomatch=0L], length)
LPERMCO datadate me RET
3 3 3 3 How did you install, may I ask? The tests pass as well, which is basically your example, with key for |
I used the following command. Did I miss anything? (I'm still getting the bug.) devtools::install_github("data.table", "Rdatatable") |
The commit is not available on the master branch yet. It's on branch |
Thanks, using the following installation method, it works now. devtools::install_github("data.table", "Rdatatable", ref = "issue_700") |
Nice, but the branch was created until we can confirm that the issue is fixed. I'd not recommend installing non-master branches. |
Sure, I did it just for testing and reverted later to 1.9.2. How would you recommend to install this branch temporarily? |
That's good. I should've mentioned "not recommend staying on non-master branches permanently". |
This unexpected behavior is best illustrated with an example. (Reproducible code is further below.) With
nomatch=0
androll=T
we should have three rows in thesapply
output, but in fact we have five rows (except forme
having three rows).Here's the code to run this example:
As a side note (not sure about it), maybe it makes sense to add a little check into data.table to catch related bugs. The check would be run, after each operation on any data.table
X
like this (together with a message to contact the devs to report a bug):I don't think it would be prohibitively expensive to run, and it would help to catch related bugs in the future based on real data that people are running. I'm mentioning this since I found this bug only by accident, and if such a check would have been in place it would have been much easier to notice.
The text was updated successfully, but these errors were encountered: