Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7861 +/- ##
=======================================
Coverage 99.01% 99.01%
=======================================
Files 88 88
Lines 17292 17295 +3
=======================================
+ Hits 17122 17125 +3
Misses 170 170 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Generated via commit bf1c6de Download link for the artifact containing the test results: ↓ atime-results.zip
|
| cols = names(order) | ||
| if (anyDuplicated(cols)) stopf("order argument has named duplicates: %s", brackify(duplicated_values(cols))) |
There was a problem hiding this comment.
2 white spaces missing in those line
| # same as above, but using setorderv | ||
| setorderv(DT, c("A", "B"), c(1, -1)) | ||
|
|
||
| # New feature: infer cols from named order mapping |
There was a problem hiding this comment.
instead of NEW feature: I would add at the end of the line (v1.19.0+) or similar, manuals are maturing fast and that way will be less stuff to update in future.
| test(2382.10, subset(DT, a > 5, drop=TRUE), subset(DF, a > 5, drop=TRUE)) | ||
|
|
||
| # #6392 setorderv() could take order=<column-order mapping> | ||
| test(2383.01, {DT1=copy(data.table(a=c(2,1,2),b=c("b","a","b"),c=c(5,10,3))); DT2=copy(DT1); m=c(a=1L,b=1L,c=-1L); setorderv(DT1, order=m); setorderv(DT2, cols=names(m), order=m); identical(DT1, DT2)}, TRUE) |
There was a problem hiding this comment.
why the extra copy for DT1? please use a setup please. Please supply x and y to test(x, y) instead of testing test(identical(x, y))
| # same as above, but using setorderv | ||
| setorderv(DT, c("A", "B"), c(1, -1)) | ||
|
|
||
| # infer cols from named order mapping (v1.18.99+) |
There was a problem hiding this comment.
| # infer cols from named order mapping (v1.18.99+) | |
| # infer cols from named order mapping |
please dont put versions here. First and foremost they will be outdated.
|
|
||
| 10. `subset()` method for data.tables supports `drop = TRUE` for consistency to data.frame, [#7859](https://github.com/Rdatatable/data.table/issues/7859). Thanks @MichaelChirico for the report and fix. | ||
|
|
||
| 11. `setorderv()` now accepts a named vector for the `order` argument. When provided, the names are used to identify the columns, allowing the `cols` argument to be omitted (#6932, @MichaelChirico). |
| test(2382.09, subset(DT, a > 10, select="a", drop=TRUE), subset(DF, a > 10, select="a", drop=TRUE)) | ||
| test(2382.10, subset(DT, a > 5, drop=TRUE), subset(DF, a > 5, drop=TRUE)) | ||
|
|
||
| # #6392 setorderv() could take order=<column-order mapping> |

closes #6932
This PR resolves the issue allowing
setorderv()to infer column names from a named order vector when the cols argument is omitted. This change reduces redundancy by eliminating the need to provide column names twice. The implementation includes a new safety check to error on duplicate names in the order mapping, and bothman/setorder.RdandNEWS.mdhave been updated to document the new functionality.