diff --git a/r/R/dplyr-arrange.R b/r/R/dplyr-arrange.R index 247a539f5278d..2f9ef61bb319a 100644 --- a/r/R/dplyr-arrange.R +++ b/r/R/dplyr-arrange.R @@ -20,7 +20,8 @@ arrange.arrow_dplyr_query <- function(.data, ..., .by_group = FALSE) { call <- match.call() - exprs <- quos(...) + exprs <- expand_across(.data, quos(...)) + if (.by_group) { # when the data is is grouped and .by_group is TRUE, order the result by # the grouping columns first diff --git a/r/tests/testthat/test-dplyr-arrange.R b/r/tests/testthat/test-dplyr-arrange.R index fee1475a44e21..edec572d10fa3 100644 --- a/r/tests/testthat/test-dplyr-arrange.R +++ b/r/tests/testthat/test-dplyr-arrange.R @@ -201,3 +201,18 @@ test_that("arrange() with bad inputs", { fixed = TRUE ) }) + +test_that("Can use across() within arrange()", { + compare_dplyr_binding( + .input %>% + arrange(across(starts_with("d"))) %>% + collect(), + example_data + ) + compare_dplyr_binding( + .input %>% + arrange(across(starts_with("d"), desc)) %>% + collect(), + example_data + ) +})