Wrong result of a join and other problems with columns of class "Period" (lubridate)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by running the reproducible left-join and row-filtering examples from the issue with R, data.table, and lubridate. Compare the returned Period values and row counts with the requested row ordering, then add regression coverage for both join and filtering behavior once the affected entry point is located.
Written by the indexing model from the issue text.
Description
For some reason, during a left-join, a column of class Period (lubridate) seems to be simply cycled through regardless of the actual row-ordering of the resulting joined data:
require(data.table)
require(lubridate)
X <- data.table(A=c('a','a','b','b','c','c'))
Y <- data.table(A=c('a','b','c'), B=period(month=1:3))
Y[X,,on='A']
A B
1: a 1m 0d 0H 0M 0S
2: a 2m 0d 0H 0M 0S
3: b 3m 0d 0H 0M 0S
4: b 1m 0d 0H 0M 0S
5: c 2m 0d 0H 0M 0S
6: c 3m 0d 0H 0M 0S
X <- data.table(A=c('c','c','b'))
Y[X,,on='A']
A B
1: c 1m 0d 0H 0M 0S
2: c 2m 0d 0H 0M 0S
3: b 3m 0d 0H 0M 0S
In fact, data.table seems to have trouble just filtering rows when it has columns of class Period (same Y as above):
Y[1,]
Error in dimnames(x) <- dn :
length of 'dimnames' [1] not equal to array extent
X <- data.table(A=c('a','b'))
Y[X,,on='A']
Error in dimnames(x) <- dn :
length of 'dimnames' [1] not equal to array extent
In addition: Warning message:
In cbind(A = c("a", "b"), B = c("1m 0d 0H 0M 0S", "2m 0d 0H 0M 0S", :
number of rows of result is not a multiple of vector length (arg 1)
Output of sessionInfo():
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
ssystem code page: 1250
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.3
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one) Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·