You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NEWS.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,8 @@
44
44
45
45
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](https://github.com/Rdatatable/data.table/issues/6932). Thanks to @MichaelChirico for the suggestion and @venom1204 for the implementation.
46
46
47
+
12.`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.
48
+
47
49
### BUG FIXES
48
50
49
51
1.`fread()` with `skip=0` and `(header=TRUE|FALSE)` no longer skips the first row when it has fewer fields than subsequent rows, [#7463](https://github.com/Rdatatable/data.table/issues/7463). Thanks @emayerhofer for the report and @ben-schwen for the fix.
\code{frank} isnotlimitedtovectors.Itaccepts \code{data.table}s (and \code{list}sand \code{data.frame}s) aswell.Itacceptsunquotedcolumnnamesprefixedwith \code{+} or \code{-} forascendingordescendingorder, fore.g., \code{frank(DT, a, -b, c, ties.method="first")} where \code{a,b,c} arecolumnsin \code{DT}.
35
+
36
+
Forvectors, \code{frank(+x)} and \code{frank(-x)} requestascendinganddescendingorderwithoutapplyingtheunaryoperatorto \code{x}.Thissupportstypeswhereunary \code{-} isnotdefined, suchas \code{Date} and \code{character}.When \code{order} isomitted, thesevectorsignsandcolumnprefixesdeterminedirection.
35
37
36
38
Inadditiontothe \code{ties.method} valuespossibleusingbase's \code{\link[base]{rank}}, it also provides another additional argument \code{"dense"} which returns the ranks without any gaps in the ranking. See examples.
37
39
}
@@ -66,6 +68,11 @@ frank(DT, ties.method="first", na.last="keep") # equivalent of above using frank
66
68
frank(DT, x, -y, ties.method="first")
67
69
# equivalent of above using frankv
68
70
frankv(DT, order=c(1L, -1L), ties.method="first")
71
+
72
+
dates = as.Date("2022-10-19") + c(1, 3, 2, 4)
73
+
frank(dates) # ascending
74
+
frank(-dates) # descending (intercepts '-' to avoid error)
0 commit comments