We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I wonder whether it is worth to implement sort_by.data.table (R 4.4.0) with internal forder instead of base order, and possibly an 'in_place' argument
sort_by.data.table
forder
order
Some improvement can be seen in my little test:
library(data.table) set.seed(1234) DT <- data.table(x=runif(1e7),y=runif(1e7)) # sort_by.data.frame with "forder" instead of "order" sort_by2 <- function (x, y, ...) { if (inherits(y, "formula")) y <- .formula2varlist(y, x) if (!is.list(y)) y <- list(y) o <- do.call(data.table:::forder, c(unname(y), list(...))) x[o, , drop = FALSE] } microbenchmark::microbenchmark(times = 1, sort_by2(DT, ~ x + y), sort_by(DT, ~ x + y) ) #> Unit: seconds #> expr min lq mean median uq max #> sort_by2(DT, ~x + y) 1.068101 1.068101 1.068101 1.068101 1.068101 1.068101 #> sort_by(DT, ~x + y) 2.317193 2.317193 2.317193 2.317193 2.317193 2.317193
Created on 2024-12-12 with reprex v2.1.1
The text was updated successfully, but these errors were encountered:
Good idea. I wouldn't offer in_place (you can use setorder() for that, with a slightly different API).
in_place
setorder()
It also looks like .formula2varlist() is key for allowing much more complicated formulas to WAI:
.formula2varlist()
mtcars |> sort_by(~I(am + mpg))
It will be a lot harder to try and translate generic formulas into, e.g., a setorderv() call.
setorderv()
Sorry, something went wrong.
No branches or pull requests
I wonder whether it is worth to implement
sort_by.data.table
(R 4.4.0) with internalforder
instead of baseorder
, and possibly an 'in_place' argumentSome improvement can be seen in my little test:
Created on 2024-12-12 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: