Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7874 +/- ##
=======================================
Coverage 99.01% 99.01%
=======================================
Files 88 88
Lines 17292 17297 +5
=======================================
+ Hits 17122 17127 +5
Misses 170 170 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Generated via commit e66c968 Download link for the artifact containing the test results: ↓ atime-results.zip
|
| test(2382.10, subset(DT, a > 5, drop=TRUE), subset(DF, a > 5, drop=TRUE)) | ||
|
|
||
| # #5489 frank could support reverse ranking | ||
| test(2383.01, frank(-as.Date(c("1992-02-27","1992-02-27","1992-01-14","1992-02-28","1992-02-01")), ties.method="min"), frankv(as.Date(c("1992-02-27","1992-02-27","1992-01-14","1992-02-28","1992-02-01")), order=-1, ties.method="min")) |
There was a problem hiding this comment.
Writing tests like is seems clearer and more maintainable:
| test(2383.01, frank(-as.Date(c("1992-02-27","1992-02-27","1992-01-14","1992-02-28","1992-02-01")), ties.method="min"), frankv(as.Date(c("1992-02-27","1992-02-27","1992-01-14","1992-02-28","1992-02-01")), order=-1, ties.method="min")) | |
| x = as.Date(c("1992-02-27","1992-02-27","1992-01-14","1992-02-28","1992-02-01")) | |
| test(2383.01, frank(-x, ties.method="min"), frankv(x, order=-1, ties.method="min")) |
|
|
||
| 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. `frank()` gains an `order` argument (matching `frankv()`) and now intercepts the unary minus symbol (e.g., `frank(-dates)`) to support reverse ranking even for types where unary `-` is not defined in R, such as `Date` or `character` vectors, [#5489](https://github.com/Rdatatable/data.table/issues/5489). Thanks @hope-data-science for the request and @venom1204 for teh implementation. |
There was a problem hiding this comment.
| 11. `frank()` gains an `order` argument (matching `frankv()`) and now intercepts the unary minus symbol (e.g., `frank(-dates)`) to support reverse ranking even for types where unary `-` is not defined in R, such as `Date` or `character` vectors, [#5489](https://github.com/Rdatatable/data.table/issues/5489). Thanks @hope-data-science for the request and @venom1204 for teh implementation. | |
| 11. `frank()` gains an `order` argument (matching `frankv()`) and now intercepts the unary minus symbol (e.g., `frank(-dates)`) to support reverse ranking even for types where unary `-` is not defined in R, such as `Date` or `character` vectors, [#5489](https://github.com/Rdatatable/data.table/issues/5489). Thanks @hope-data-science for the request and @venom1204 for the implementation. |
| test(2383.03, frank(-idates), frankv(idates, order=-1L)) | ||
| it = as.ITime(c("10:00:00", "10:00:00", "08:00:00", "12:00:00", "09:00:00")) | ||
| test(2383.05, frank(-it), frankv(it, order=-1L)) | ||
| test(2383.04, frank(DT, -x, y), frankv(DT, cols=c("x","y"), order=c(-1L, 1L))) |
There was a problem hiding this comment.
test order is wrong. and you probably would want to instantiate DT before using it and not use a DT from a previous test
|
|
||
| frank = function(x, ..., na.last=TRUE, ties.method=c("average", "first", "last", "random", "max", "min", "dense")) { | ||
| frank = function(x, ..., order=1L, na.last=TRUE, ties.method=c("average", "first", "last", "random", "max", "min", "dense")) { | ||
| if (missing(order)) { |
There was a problem hiding this comment.
why are we only intercepting when order is missing, e.g. frank(-dates, order=-1L)
Shouldn't we warn the user in such cases?
| test(2383.05, frank(-it), frankv(it, order=-1L)) | ||
| test(2383.04, frank(DT, -x, y), frankv(DT, cols=c("x","y"), order=c(-1L, 1L))) | ||
| DT = data.table(a=c(1,2,1), b=c(1,1,2)) | ||
| test(2383.06, frank(DT, order=-1L), frankv(DT, order=-1L)) |
There was a problem hiding this comment.
how should explicit order interact with -, e.g. frank(-x, order=-1L)
| dates = as.Date("2022-10-19") + c(1, 3, 2, 4) | ||
| frank(dates) # ascending | ||
| frank(-dates) # descending (intercepts '-' to avoid error) | ||
| frank(dates, order=-1L) # same as above |
There was a problem hiding this comment.
| frank(dates, order=-1L) # same as above | |
| frank(dates, order=-1L) # also descending |
|
|
||
| dates = as.Date("2022-10-19") + c(1, 3, 2, 4) | ||
| frank(dates) # ascending | ||
| frank(-dates) # descending (intercepts '-' to avoid error) |
There was a problem hiding this comment.
if we intercept - should we also intercept + for ascending order?

closes #5489
this pr adds the order parameter to
frank()to bring it into parity withfrankv().Implements internal interception of the unary minus symbol in
frank(x). This allows reverse ranking for types where R does not define unary .